tc-build-release #119
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: Update Package Index | |
| on: | |
| # Sent by tc-build and core_arduino_avr after publishing releases. | |
| repository_dispatch: | |
| types: [tc-build-release, core-release] | |
| workflow_dispatch: | |
| inputs: | |
| channel: | |
| description: 'Which index to refresh' | |
| type: choice | |
| options: [both, stable, nightly] | |
| default: both | |
| schedule: | |
| # Safety net in case a dispatch or secret is missing. | |
| - cron: '0 6 * * *' | |
| # One refresh at a time: jobs commit to main. | |
| concurrency: | |
| group: update-package-index | |
| cancel-in-progress: false | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| # persist-credentials stays enabled: this job pushes commits to main. | |
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Resolve channels | |
| id: channels | |
| env: | |
| EVENT_TYPE: ${{ github.event_name }} | |
| PAYLOAD_CHANNEL: ${{ github.event.client_payload.channel }} | |
| INPUT_CHANNEL: ${{ inputs.channel }} | |
| run: | | |
| if [ "$EVENT_TYPE" = "repository_dispatch" ]; then | |
| CHANNEL="${PAYLOAD_CHANNEL:-both}" | |
| elif [ "$EVENT_TYPE" = "workflow_dispatch" ]; then | |
| CHANNEL="${INPUT_CHANNEL:-both}" | |
| else | |
| CHANNEL="both" | |
| fi | |
| case "$CHANNEL" in | |
| stable) echo "channels=stable" >> "$GITHUB_OUTPUT" ;; | |
| nightly) echo "channels=nightly" >> "$GITHUB_OUTPUT" ;; | |
| *) echo "channels=stable nightly" >> "$GITHUB_OUTPUT" ;; | |
| esac | |
| # Sequential on purpose: each channel commits to main. | |
| - name: Update indexes | |
| env: | |
| CHANNELS: ${{ steps.channels.outputs.channels }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| for channel in ${CHANNELS}; do | |
| echo "::group::${channel}" | |
| python3 update_index.py --channel "${channel}" --auto | |
| if ! git diff --quiet; then | |
| git commit -am "index: refresh ${channel} channel" | |
| git push | |
| else | |
| echo "No changes for ${channel}." | |
| fi | |
| echo "::endgroup::" | |
| done |