Sync main with upstream and build Docker image #64
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
| on: | |
| schedule: | |
| - cron: "0 7 * * 1" | |
| # scheduled at 07:00 every Monday | |
| workflow_dispatch: # click the button on Github repo! | |
| name: Sync main with upstream and build Docker image | |
| jobs: | |
| sync_with_upstream: | |
| runs-on: ubuntu-latest | |
| name: Sync main with upstream latest and build | |
| outputs: | |
| has_new_commits: ${{ steps.sync.outputs.has_new_commits }} | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Pull (Fast-Forward) upstream changes | |
| id: sync | |
| uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 | |
| with: | |
| target_repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| target_sync_branch: main | |
| upstream_sync_repo: lukevella/rallly | |
| upstream_sync_branch: main | |
| - name: Check for new commits | |
| if: steps.sync.outputs.has_new_commits == 'true' | |
| run: echo "There were new commits. Continue to build and push the image." | |
| push_to_registry: | |
| needs: sync_with_upstream | |
| if: needs.sync_with_upstream.outputs.has_new_commits == 'true' || github.event_name == 'workflow_dispatch' | |
| name: Push Docker image to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Optimize disk space | |
| uses: sctg-development/clean-image-for-docker@v1 | |
| - name: Check out the repo | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: "arm64" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract latest version from lukevella/rallly | |
| id: version | |
| run: | | |
| OWNER="lukevella" | |
| REPO="rallly" | |
| today_date=$(date +"%Y%m%d") | |
| latest_release=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/releases/latest") | |
| release_name=$(echo "$latest_release" | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4) | |
| # Format the release string properly for Docker tags (no quotes, proper format) | |
| echo "release=${release_name}-${today_date}" >> $GITHUB_OUTPUT | |
| # For debugging | |
| echo "Generated tag: ${release_name}-${today_date}" | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| continue-on-error: true | |
| with: | |
| file: ./apps/web/Dockerfile.sctg | |
| context: . | |
| build-args: | | |
| SELF_HOSTED=false | |
| platforms: linux/arm64, linux/amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha | |
| push: true | |
| tags: sctg/rallly:${{ steps.version.outputs.release }}, sctg/rallly:latest |