diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 8213c97..8509f60 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -17,6 +17,7 @@ jobs: uses: actions/checkout@v4 # https://github.com/superfly/flyctl-actions + # https://github.com/marketplace/actions/github-action-for-flyctl - name: Setup flyctl uses: superfly/flyctl-actions/setup-flyctl@master @@ -30,6 +31,50 @@ jobs: # https://github.com/cao7113/hello-api-elixir/settings/secrets/actions FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + push-to-registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + # attestations: write + id-token: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + # https://github.com/docker/login-action + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # https://github.com/docker/metadata-action + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: cao7113/hello-api-elixir + + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # - name: Generate artifact attestation + # uses: actions/attest-build-provenance@v1 + # with: + # subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + # subject-digest: ${{ steps.push.outputs.digest }} + # push-to-registry: true + release-tar: # strategy: # matrix: @@ -69,6 +114,7 @@ jobs: - name: Make Github release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') + # todo: add runner.os & runner.arch info with: files: _build/prod/*.tar.gz