Unified · Split
| @@ -0,0 +1,57 @@ | ||
| 1 | +name: Build and Push Docker Images | |
| 2 | + | |
| 3 | +on: | |
| 4 | + schedule: | |
| 5 | + - cron: '0 0 1 * *' # Run monthly on the 1st | |
| 6 | + workflow_dispatch: # Allow manual triggers | |
| 7 | + | |
| 8 | +env: | |
| 9 | + REGISTRY: ghcr.io | |
| 10 | + IMAGE_NAME: ${{ github.repository }} | |
| 11 | + | |
| 12 | +jobs: | |
| 13 | + build-and-push: | |
| 14 | + runs-on: ubuntu-latest | |
| 15 | + permissions: | |
| 16 | + contents: read | |
| 17 | + packages: write | |
| 18 | + | |
| 19 | + steps: | |
| 20 | + - name: Checkout repository | |
| 21 | + uses: actions/checkout@v4 | |
| 22 | + | |
| 23 | + - name: Log in to the Container registry | |
| 24 | + uses: docker/login-action@v3 | |
| 25 | + with: | |
| 26 | + registry: ${{ env.REGISTRY }} | |
| 27 | + username: ${{ github.actor }} | |
| 28 | + password: ${{ secrets.GITHUB_TOKEN }} | |
| 29 | + | |
| 30 | + - name: Extract metadata for Docker | |
| 31 | + id: meta | |
| 32 | + uses: docker/metadata-action@v5 | |
| 33 | + with: | |
| 34 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| 35 | + tags: | | |
| 36 | + type=raw,value=latest | |
| 37 | + type=raw,value={{date 'YYYYMMDD'}} | |
| 38 | + | |
| 39 | + - name: Build and push regular image | |
| 40 | + uses: docker/build-push-action@v5 | |
| 41 | + with: | |
| 42 | + context: . | |
| 43 | + file: ./Dockerfile | |
| 44 | + push: true | |
| 45 | + tags: ${{ steps.meta.outputs.tags }} | |
| 46 | + labels: ${{ steps.meta.outputs.labels }} | |
| 47 | + | |
| 48 | + - name: Build and push Alpine image | |
| 49 | + uses: docker/build-push-action@v5 | |
| 50 | + with: | |
| 51 | + context: . | |
| 52 | + file: ./Dockerfile-alpine | |
| 53 | + push: true | |
| 54 | + tags: | | |
| 55 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine | |
| 56 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-{{date 'YYYYMMDD'}} | |
| 57 | + labels: ${{ steps.meta.outputs.labels }} | |