Skip to content

Commit

Permalink
Merge pull request #1 from mkpro118/push-image
Browse files Browse the repository at this point in the history
Added workflow to automatically deploy to DockerHub on release
  • Loading branch information
mkpro118 authored Jun 16, 2024
2 parents c39a480 + 26efda8 commit 51af2d8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/push-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Push image to Docker Hub

on:
release:
types: [published]

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

jobs:
push_to_registry:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Get current date
id: date
run: echo "NOW=$(date +'%y.%-m.%-d')" >> $GITHUB_ENV

- uses: actions/checkout@v4

- name: Login in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_PAT }}

- name: Build and push
uses: docker/build-push-action@v5
id: push
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.NOW }}
- 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 51af2d8

Please sign in to comment.