Weekly Docker Build #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Weekly Docker Build | |
| on: | |
| schedule: | |
| - cron: '0 3 * * 0' # Every Sunday at 03:00 UTC | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-and-push: | |
| name: Build and Push Docker Images for Latest Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Fetch all tags | |
| run: git fetch --tags --force | |
| - name: Get latest release tag | |
| id: get_tag | |
| run: | | |
| # Get the latest release tag (sorted by version) | |
| tag=$(git tag --list 'v*' --sort=-v:refname | head -n 1) | |
| echo "tag=$tag" >> $GITHUB_OUTPUT | |
| # Extract major version (e.g., v1 from v1.2.3) | |
| major=$(echo "$tag" | grep -oE '^v[0-9]+') | |
| echo "major=$major" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata for app | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/app | |
| tags: | | |
| type=raw,value=${{ steps.get_tag.outputs.tag }} | |
| type=raw,value=${{ steps.get_tag.outputs.major }} | |
| type=raw,value=latest | |
| - name: Build and push Docker image for app | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./App.Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Upload release docker-compose and env.example as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-compose-and-env | |
| path: | | |
| deploy/dockerized/docker-compose.release.yml | |
| deploy/dockerized/env.example | |
| # Optionally, repeat for workers image if needed | |
| # - name: Extract metadata for workers | |
| # id: meta_workers | |
| # uses: docker/metadata-action@v5 | |
| # with: | |
| # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/workers | |
| # tags: | | |
| # type=raw,value=${{ steps.get_tag.outputs.tag }} | |
| # type=raw,value=${{ steps.get_tag.outputs.major }} | |
| # type=raw,value=latest | |
| # | |
| # - name: Build and push Docker image for workers | |
| # uses: docker/build-push-action@v5 | |
| # with: | |
| # context: . | |
| # file: ./BackgroundJobs.Dockerfile | |
| # push: true | |
| # tags: ${{ steps.meta_workers.outputs.tags }} | |
| # labels: ${{ steps.meta_workers.outputs.labels }} | |
| # cache-from: type=gha | |
| # cache-to: type=gha,mode=max | |
| # platforms: linux/amd64,linux/arm64 |