Repository navigation
Auto-update runner from upstream #56
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: Auto-update runner from upstream | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # daily at 06:00 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| check-and-update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Add upstream remote | |
| run: git remote add upstream https://github.com/actions/runner.git || true | |
| - name: Run merge script | |
| id: merge | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| chmod +x ./merge-runner-latest.sh | |
| set +e | |
| ./merge-runner-latest.sh | |
| RC=$? | |
| set -e | |
| if [ $RC -eq 0 ]; then | |
| echo "updated=true" >> "$GITHUB_OUTPUT" | |
| elif [ $RC -eq 2 ]; then | |
| echo "Already up to date" | |
| echo "updated=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Merge script failed with exit code $RC" | |
| exit $RC | |
| fi | |
| - name: Check for unpushed tag | |
| id: tagcheck | |
| if: steps.merge.outputs.updated != 'true' | |
| run: | | |
| YOLO_VERSION=$(cat yoloVersion) | |
| if ! git ls-remote --tags --refs origin "$YOLO_VERSION" | grep -q .; then | |
| echo "Tag $YOLO_VERSION missing from remote, rebuilding" | |
| git tag "$YOLO_VERSION" | |
| echo "rebuild=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Push commits | |
| if: steps.merge.outputs.updated == 'true' | |
| run: git push origin main | |
| - name: Login to Docker Hub | |
| if: steps.merge.outputs.updated == 'true' || steps.tagcheck.outputs.rebuild == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| if: steps.merge.outputs.updated == 'true' || steps.tagcheck.outputs.rebuild == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Read version | |
| if: steps.merge.outputs.updated == 'true' || steps.tagcheck.outputs.rebuild == 'true' | |
| id: version | |
| run: | | |
| VERSION=$(cat yoloVersion) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Build and push Docker image | |
| if: steps.merge.outputs.updated == 'true' || steps.tagcheck.outputs.rebuild == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| docker.io/${{ secrets.DOCKERHUB_USERNAME }}/gha-runner-yolo:${{ steps.version.outputs.version }} | |
| docker.io/${{ secrets.DOCKERHUB_USERNAME }}/gha-runner-yolo:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Push tag | |
| if: steps.merge.outputs.updated == 'true' || steps.tagcheck.outputs.rebuild == 'true' | |
| run: | | |
| YOLO_VERSION=$(cat yoloVersion) | |
| git push origin "refs/tags/${YOLO_VERSION}" |