From 08b80c35be26b8815d310e9f3056d6633eef54a6 Mon Sep 17 00:00:00 2001 From: Chaitanya Rahalkar Date: Sat, 14 Dec 2024 14:23:08 -0600 Subject: [PATCH] Update docker-build.yml --- .github/workflows/docker-build.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index f2dc8669..6b8dad08 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,24 +1,25 @@ name: Build and Push Docker Images - on: schedule: - - cron: '0 0 1 * *' # Run monthly on the 1st + - cron: '0 0 1 *'* # Run monthly on the 1st workflow_dispatch: # Allow manual triggers - env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - + TAG_DATE: ${{ format('{0}{1}{2}', github.event.repository.pushed_at.substring(0,4), github.event.repository.pushed_at.substring(5,7), github.event.repository.pushed_at.substring(8,10)) }} jobs: build-and-push: runs-on: ubuntu-latest permissions: contents: read packages: write - steps: - name: Checkout repository uses: actions/checkout@v4 + + - name: Set current date + id: date + run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV - name: Log in to the Container registry uses: docker/login-action@v3 @@ -34,7 +35,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=latest - type=raw,value={{date 'YYYYMMDD'}} + type=raw,value=${{ env.DATE }} - name: Build and push regular image uses: docker/build-push-action@v5 @@ -53,5 +54,5 @@ jobs: push: true tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-${TAG_DATE} - labels: ${{ steps.meta.outputs.labels }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-${{ env.DATE }} + labels: ${{ steps.meta.outputs.labels }}