Update README dependencies #9
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 README dependencies | |
| # Keeps the Appodeal dependency lists in README.md in sync with the live | |
| # Dependencies Wizard API (URL from the APPODEAL_API_URL repository variable). | |
| # The SDK version comes from package.json, so a version bump (push) refreshes the | |
| # lists; the daily schedule catches adapter-version changes published between releases. | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'package.json' | |
| - 'scripts/update-readme-deps.mjs' | |
| schedule: | |
| # Daily at 06:00 UTC. | |
| - cron: '0 6 * * *' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: update-readme-deps | |
| cancel-in-progress: true | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Regenerate README dependency lists | |
| # URL comes only from the APPODEAL_API_URL repository variable | |
| # (Settings → Secrets and variables → Actions → Variables). No hardcoded fallback — | |
| # if the variable is unset the script fails loudly. | |
| env: | |
| APPODEAL_API_URL: ${{ vars.APPODEAL_API_URL }} | |
| run: node scripts/update-readme-deps.mjs | |
| - name: Create PR if README changed | |
| # master is protected (changes must go through a PR), so the bot opens a PR as | |
| # github-actions[bot]. A different identity (the App below) approves and merges it. | |
| id: pr | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if git diff --quiet -- README.md; then | |
| echo "README dependencies already up to date." | |
| echo "created=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| BRANCH="chore/update-readme-deps-${{ github.run_id }}-${{ github.run_attempt }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git switch -c "$BRANCH" | |
| git add README.md | |
| git commit -m "chore: sync README dependency lists from Wizard API" | |
| git push origin "$BRANCH" | |
| gh pr create --base master --head "$BRANCH" \ | |
| --title "chore: sync README dependency lists from Wizard API" \ | |
| --body "Automated update from the Appodeal Dependencies Wizard API." | |
| echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" | |
| echo "created=true" >> "$GITHUB_OUTPUT" | |
| - name: Generate App token for approval | |
| # A second identity is required: github-actions[bot] (the PR author) cannot approve | |
| # its own PR. The GitHub App acts as the reviewer whose approval branch protection counts. | |
| if: steps.pr.outputs.created == 'true' | |
| id: app-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - name: Approve and merge PR | |
| if: steps.pr.outputs.created == 'true' | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| gh pr review "${{ steps.pr.outputs.branch }}" --approve | |
| gh pr merge "${{ steps.pr.outputs.branch }}" --squash --delete-branch |