From f03bb971e4a493989746e25b441878541c3426c4 Mon Sep 17 00:00:00 2001 From: David de Boer Date: Mon, 29 Jul 2024 12:11:37 +0200 Subject: [PATCH] ci: Build and deploy --- .github/workflows/deploy.yml | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..52ebfbc --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,61 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + build: + strategy: + matrix: + app: [nuxt, strapi] + outputs: + app: ${{ matrix.app }} + image: ${{ steps.meta.outputs.version }} + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository }}-${{ matrix.app }} + - uses: docker/build-push-action@v6 + id: push + with: + context: ${{ matrix.app }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.output.labels }} + - uses: actions/attest-build-provenance@v1 + with: + subject-name: ghcr.io/${{ github.repository }}-${{ matrix.app }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Store credentials + run: doctl kubernetes cluster kubeconfig save nde + + - name: Update deployment + run: | + kubectl set image deployment/${{ needs.build.outputs.app }} app=${{ needs.build.outputs.image }} + + - name: Verify deployment + run: kubectl rollout status deployment/${{ needs.build.outputs.app }} --timeout=120s