Unified · Split
| @@ -2,11 +2,10 @@ name: Build and Push Docker Images · 1 unmodified line | |||
| 2 | on: | 2 | on: |
| 3 | schedule: | 3 | schedule: |
| 4 | - cron: '0 0 1 * *' # Run monthly on the 1st | 4 | - cron: '0 0 1 * *' # Run monthly on the 1st |
| 5 | workflow_dispatch: | 5 | workflow_dispatch: # Allow manual triggers |
| 6 | env: | 6 | env: |
| 7 | REGISTRY: ghcr.io | 7 | REGISTRY: ghcr.io |
| 8 | IMAGE_NAME: ${{ github.repository }} | 8 | IMAGE_NAME: ${{ github.repository }} |
| 9 | 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)) }} | ||
| 10 | jobs: | 9 | jobs: |
| 11 | build-and-push: | 10 | build-and-push: |
| 12 | runs-on: ubuntu-latest | 11 | runs-on: ubuntu-latest |
| @@ -16,10 +15,6 @@ jobs: · 3 unmodified lines | |||
| 16 | steps: | 15 | steps: |
| 17 | - name: Checkout repository | 16 | - name: Checkout repository |
| 18 | uses: actions/checkout@v4 | 17 | uses: actions/checkout@v4 |
| 19 | |||
| 20 | - name: Set current date | ||
| 21 | id: date | ||
| 22 | run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV | ||
| 23 | 18 | ||
| 24 | - name: Log in to the Container registry | 19 | - name: Log in to the Container registry |
| 25 | uses: docker/login-action@v3 | 20 | uses: docker/login-action@v3 |
| @@ -35,7 +30,7 @@ jobs: · 9 unmodified lines | |||
| 35 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | 30 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 36 | tags: | | 31 | tags: | |
| 37 | type=raw,value=latest | 32 | type=raw,value=latest |
| 38 | type=raw,value=${{ env.DATE }} | 33 | type=raw,value={{date 'YYYYMMDD'}} |
| 39 | 34 | ||
| 40 | - name: Build and push regular image | 35 | - name: Build and push regular image |
| 41 | uses: docker/build-push-action@v5 | 36 | uses: docker/build-push-action@v5 |
| @@ -54,5 +49,5 @@ jobs: · 12 unmodified lines | |||
| 54 | push: true | 49 | push: true |
| 55 | tags: | | 50 | tags: | |
| 56 | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine | 51 | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine |
| 57 | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-${{ env.DATE }} | 52 | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-{{date 'YYYYMMDD'}} |
| 58 | labels: ${{ steps.meta.outputs.labels }} | 53 | labels: ${{ steps.meta.outputs.labels }} |