Skip to content

Commit

Permalink
Add CI workflow to build and push Docker images
Browse files Browse the repository at this point in the history
On every release, a new image, containing the latest PyPI package, is
built and pushed to Docker Hub:
https://hub.docker.com/r/upstreamdata/goosebit
  • Loading branch information
easybe committed Aug 30, 2024
1 parent a7866b4 commit ddacd94
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker

on:
workflow_run:
workflows: ["PyPI"]
types:
- completed

jobs:
docker:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set GOOSEBIT_VERSION env var
run: |
if [ $GITHUB_REF_TYPE = tag ]; then
tag=$GITHUB_REF_NAME
else
echo "This job is only supposed to be run for Git tags"
exit 1
fi
echo "GOOSEBIT_VERSION=${tag#v}" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: upstreamdata/goosebit

- name: Build and push Docker image
id: push
uses: docker/[email protected]
with:
context: docker
build-args: GOOSEBIT_VERSION=${{ env.GOOSEBIT_VERSION }}
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

0 comments on commit ddacd94

Please sign in to comment.