Skip to content

Commit

Permalink
Merge pull request #8 from huh-sters/s3than/use-repo-name
Browse files Browse the repository at this point in the history
  • Loading branch information
s3than authored Jan 23, 2025
2 parents 32c58bf + 0328507 commit 751dfd3
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ jobs:
- name: Test with pytest
run: pdm run test

push_to_docker_hub:
name: Push Docker image to Docker Hub
build_docker_image:
name: Build & Push Docker image
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
Expand All @@ -44,54 +46,51 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: centurix/traffcap:latest

push_to_ghcr:
name: Push Docker image to GHCR
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
id: meta_ghcr
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ghcr.io/${{ env.IMAGE_NAME }}
tags: |
# minimal (short sha)
type=sha
# set latest tag for master branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
- name: Extract metadata (tags, labels) for Docker
id: meta_docker
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
centurix/traffcap
tags: |
# minimal (short sha)
type=sha
# set latest tag for master branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ steps.meta_ghcr.outputs.tags }}
${{ steps.meta_docker.outputs.tags }}
labels: |
${{ steps.meta_ghcr.outputs.labels }}
${{ steps.meta_docker.outputs.labels }}
- name: Generate artifact attestation
- name: Generate ghcr artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-name: ghcr.io/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit 751dfd3

Please sign in to comment.