Skip to content

Commit

Permalink
fix: try push image to dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
cao7113 committed Jul 8, 2024
1 parent 57f8da9 commit 1e05886
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1e05886

Please sign in to comment.