Sync upstream and create version tags #1
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: Sync upstream and create version tags | |
| on: | |
| schedule: | |
| - cron: '17 */6 * * *' # Every 6 hours at :17 | |
| workflow_dispatch: # Manual trigger | |
| jobs: | |
| sync-and-tag: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout ci branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ci | |
| path: ci-checkout | |
| - name: Create a bare working repo | |
| run: | | |
| git clone --bare "https://github.com/${{ github.repository }}.git" repo.git | |
| env: | |
| GIT_TERMINAL_PROMPT: '0' | |
| - name: Add upstream remote and fetch | |
| run: | | |
| cd repo.git | |
| git remote add upstream https://github.com/VirtualBox/virtualbox.git | |
| git fetch upstream --prune | |
| env: | |
| GIT_TERMINAL_PROMPT: '0' | |
| - name: Sync branches from upstream | |
| run: | | |
| cd repo.git | |
| # Sync main | |
| echo "::group::Syncing main" | |
| git fetch upstream main | |
| git update-ref refs/heads/main refs/remotes/upstream/main | |
| git push origin main | |
| echo "::endgroup::" | |
| # Sync all upstream VBox-* branches | |
| for ref in $(git for-each-ref --format='%(refname:short)' refs/remotes/upstream/ \ | |
| | grep '^upstream/VBox-'); do | |
| branch="${ref#upstream/}" | |
| echo "::group::Syncing $branch" | |
| git update-ref "refs/heads/$branch" "$ref" | |
| git push origin "$branch" | |
| echo "::endgroup::" | |
| done | |
| env: | |
| GIT_TERMINAL_PROMPT: '0' | |
| - name: Create version tags | |
| run: | | |
| cd repo.git | |
| chmod +x "$GITHUB_WORKSPACE/ci-checkout/.github/scripts/create-version-tags.sh" | |
| "$GITHUB_WORKSPACE/ci-checkout/.github/scripts/create-version-tags.sh" --push |