Skip to content

Commit

Permalink
build: add GitHub Action for pushing to docker hub (#15)
Browse files Browse the repository at this point in the history
* add action until extracting version

* remove extra quotes

* enable extended regex

* test if the first grep is working

* use Perl-compatible regex

* add build and push step
  • Loading branch information
jljl1337 authored Dec 21, 2024
1 parent bf12487 commit d29e32a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish

on:
push:
branches:
- main
path:
- pyproject.toml

jobs:
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

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract version for tagging
id: version
run: echo "version=$(grep -m 1 version pyproject.toml | grep -P '\d.\d.\d' -o)" >> $GITHUB_OUTPUT

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: jljl1337/testpod:latest,jljl1337/testpod:${{ steps.version.outputs.version }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit d29e32a

Please sign in to comment.