Sync Calico API #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
| # Sync API files from projectcalico/calico into this repo. | |
| # Creates or updates a PR if anything changed. | |
| --- | |
| name: Sync Calico API | |
| on: # yamllint disable-line rule:truthy | |
| schedule: | |
| - cron: '0 * * * *' # every hour | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| discover-branches: | |
| if: github.repository == 'projectcalico/api' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| branches: ${{ steps.branches.outputs.branches }} | |
| steps: | |
| - name: Discover branches | |
| id: branches | |
| run: | | |
| # Get master + the two most recent release branches (by semver). | |
| branches=$(gh api repos/${{ github.repository }}/branches --paginate --jq ' | |
| [.[] | select(.name | test("^release-v[0-9]+\\.[0-9]+$")) | .name] | |
| | sort_by(ltrimstr("release-v") | split(".") | map(tonumber)) | |
| | .[-2:] | |
| | ["master"] + . | |
| ') | |
| echo "branches=${branches}" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| sync: | |
| needs: discover-branches | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: sync-calico-api-${{ matrix.branch }} | |
| cancel-in-progress: true | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| branch: ${{ fromJson(needs.discover-branches.outputs.branches) }} | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| - name: Configure git auth | |
| run: | | |
| git config --global url."https://github.com/".insteadOf "git@github.com:" | |
| - name: Sync API from calico monorepo | |
| run: make -f Makefile.local update | |
| - uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "Automatic API update from projectcalico/calico ${{ matrix.branch }}" | |
| branch: auto-api-update-${{ matrix.branch }} | |
| base: ${{ matrix.branch }} | |
| title: "Auto: sync API from projectcalico/calico [${{ matrix.branch }}]" | |
| body: | | |
| Automated sync of API files from `projectcalico/calico` `${{ matrix.branch }}` | |
| branch into this repo via `make -f Makefile.local update`. | |
| Triggered by scheduled workflow. | |
| labels: docs-not-required,release-note-not-required,merge-when-ready,delete-branch | |
| delete-branch: true |