Skip to content

Commit

Permalink
ci: Build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Jul 29, 2024
1 parent 8a40d46 commit 27e0a16
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
on:
workflow_call:
inputs:
app:
required: true
type: string

jobs:
build:
outputs:
image: ${{ steps.meta.outputs.tags }}
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 }}-${{ inputs.app }}
# Disable ‘main’ tag to tag with SHA only.
tags: |
# type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v6
id: push
with:
context: ${{ inputs.app }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.output.labels }}
push: true
- uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository }}-${{ inputs.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/makemyflix-${{ inputs.app }} app=${{ needs.build.outputs.image }}
- name: Verify deployment
run: kubectl rollout status deployment/makemyflix-${{ inputs.app }} --timeout=120s
14 changes: 14 additions & 0 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
push:
branches:
- main

jobs:
build-deploy-app:
strategy:
matrix:
app: [nuxt, strapi]
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
app: ${{ matrix.app }}

0 comments on commit 27e0a16

Please sign in to comment.