Skip to content

Commit

Permalink
fix: try push image to github packages
Browse files Browse the repository at this point in the history
  • Loading branch information
cao7113 committed Jul 8, 2024
1 parent e786b46 commit d53f3a3
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
permissions:
contents: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
fly-deploy:
name: Deploy fly app
Expand All @@ -31,13 +35,13 @@ jobs:
# https://github.com/cao7113/hello-api-elixir/settings/secrets/actions
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

push-dockerhub:
name: Push Docker image to Docker Hub
push-images:
name: Push Docker image to Docker Hub and Github Packages
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
# attestations: write
attestations: write
id-token: write
steps:
- name: Check out the repo
Expand All @@ -50,12 +54,21 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_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
images: |
cao7113/hello-api-elixir
ghcr.io/${{ github.repository }}
# https://github.com/docker/build-push-action
- name: Build and push Docker image
Expand All @@ -68,13 +81,13 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

## enable below??? https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-docker-hub
# - 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
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-docker-hub
- 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:
Expand Down

0 comments on commit d53f3a3

Please sign in to comment.