github.com/grafana/pyroscope@v1.18.0/.github/workflows/update-contributors.yml (about) 1 name: Update Contributors in README 2 3 on: 4 schedule: 5 - cron: '0 0 1 * *' 6 workflow_dispatch: 7 8 permissions: 9 contents: read 10 id-token: write 11 12 jobs: 13 update-contributors: 14 if: github.repository == 'grafana/pyroscope' 15 runs-on: ubuntu-latest 16 17 steps: 18 - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 19 with: 20 persist-credentials: 'false' 21 ref: main 22 - id: get-secrets 23 uses: grafana/shared-workflows/actions/get-vault-secrets@bae259f9ed5b6fcb050e3b58adf7aee776d4edb5 24 with: 25 repo_secrets: | 26 GITHUB_APP_ID=pyroscope-development-app:app-id 27 GITHUB_APP_INSTALLATION_ID=pyroscope-development-app:app-installation-id 28 GITHUB_APP_PRIVATE_KEY=pyroscope-development-app:private-key 29 30 - name: Generate token 31 id: generate_token 32 uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 33 with: 34 app-id: ${{ env.GITHUB_APP_ID }} 35 private-key: ${{ env.GITHUB_APP_PRIVATE_KEY }} 36 owner: ${{ github.repository_owner }} 37 permission-contents: write 38 permission-pull-requests: write 39 repositories: | 40 pyroscope 41 - name: Get GitHub App User ID 42 id: get-user-id 43 env: 44 GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} 45 run: | 46 APP_BOT="${{ steps.generate_token.outputs.app-slug }}[bot]" 47 echo "user-id=$(gh api "/users/${APP_BOT}" --jq .id)" >> "$GITHUB_OUTPUT" 48 - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6 49 with: 50 go-version: 1.24.12 51 - name: Update contributors 52 run: make update-contributors 53 54 - name: Commit and push changes 55 env: 56 GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} 57 run: | 58 APP_BOT="${{ steps.generate_token.outputs.app-slug }}[bot]" 59 git config --local user.name "${APP_BOT}" 60 git config --local user.email "${{ steps.get-user-id.outputs.user-id }}+${APP_BOT}@users.noreply.github.com" 61 62 if ! git diff --exit-code README.md; then 63 BRANCH_NAME="update-contributors-$(date +%Y%m%d)" 64 git checkout -b "${BRANCH_NAME}" 65 git add README.md 66 git commit -m 'docs: updates the list of contributors in README' 67 git push https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git HEAD:${BRANCH_NAME} 68 69 # Check if PR already exists for this branch 70 EXISTING_PR=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[0].number' || echo "") 71 if [ -z "$EXISTING_PR" ]; then 72 gh pr create \ 73 --title "docs: updates the list of contributors in README" \ 74 --body "This PR automatically updates the list of contributors in the README." \ 75 --base main \ 76 --head "${BRANCH_NAME}" 77 else 78 echo "PR #${EXISTING_PR} already exists for this branch" 79 fi 80 fi