|
| 1 | +name: Receive repository dispatch event |
| 2 | + |
| 3 | +on: |
| 4 | + # Listen to a repository dispatch event by the name of `dispatch-event` |
| 5 | + repository_dispatch: |
| 6 | + types: [update-references] |
| 7 | + workflow_dispatch: |
| 8 | +env: |
| 9 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + create-pull-request: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout Repo |
| 16 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 17 | + |
| 18 | + - name: Setup Node.js 20 |
| 19 | + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 |
| 20 | + with: |
| 21 | + node-version: 20.x |
| 22 | + |
| 23 | + - name: Set github commit user |
| 24 | + env: |
| 25 | + GITHUB_EMAIL: ${{ vars.GH_EMAIL }} |
| 26 | + GITHUB_USER: ${{ vars.GH_USER }} |
| 27 | + run: | |
| 28 | + git config --global user.email $GITHUB_EMAIL |
| 29 | + git config --global user.name $GITHUB_USER |
| 30 | +
|
| 31 | + # Set branch name to be used as environment variable |
| 32 | + - name: Set Branch Name |
| 33 | + run: echo "BRANCH_NAME=$(echo update-ref-$(date +%s))" >> $GITHUB_ENV |
| 34 | + |
| 35 | + # Create new branch, download, and commit changes to the new branch |
| 36 | + - name: Create new branch |
| 37 | + run: | |
| 38 | + git checkout -b ${{ env.BRANCH_NAME }} |
| 39 | + curl -L -o ${{ vars.REF_LOC }} ${{ vars.REMOTE_REF }} |
| 40 | + node tasks/clean-references.mjs |
| 41 | + git add ${{ vars.REF_LOC }} ${{ vars.CLEAN_LOC }} |
| 42 | + git commit -m "updating references" |
| 43 | + git push -u origin ${{ env.BRANCH_NAME }} |
| 44 | +
|
| 45 | + # Open pull request |
| 46 | + - name: Create Pull Request |
| 47 | + run: gh pr create -B main -H ${{ env.BRANCH_NAME }} --title 'Merge ${{ env.BRANCH_NAME }} into main' --body 'Created by Github action' |
0 commit comments