Trigger PR #9
This file contains 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: Trigger PR | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
description: 'Name of natural wonder, lowercase with dashes' | |
required: true | |
sql: | |
description: 'The SQL INSERT statement to include in the PR' | |
required: true | |
permissions: | |
contents: write | |
env: | |
PUSH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
trigger_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create Branch | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "nwm-bot" | |
git checkout -b feat/${{ github.event.inputs.name}} | |
echo "${{ github.event.inputs.sql }}" >> static/changes.sql | |
git add static/changes.sql | |
git commit -m "feat: add wonder ${{ github.event.inputs.name}}" | |
git push --set-upstream https://x-access-token:[email protected]/${{ github.repository }}.git \ | |
feat/${{ github.event.inputs.name }}:feat/${{ github.event.inputs.name }} | |
- name: Create PR via API | |
run: | | |
PAT='github_'"pat_11BC"'ZL43Q0sWKIX4ijCone_iuLVXdzQO94OjdvSCyEEVp6aI90G0XPumeUHx9M4EgpLERYVN6Sa9W05UE8' | |
response=$(curl -X POST \ | |
-H "Authorization: Bearer ${PAT}" \ | |
-H "Accept: application/vnd.github+json" \ | |
-d '{ | |
"title": "New Wonder: ${{ github.event.inputs.name }}", | |
"base": "main", | |
"head": "feat/${{ github.event.inputs.name }}" | |
}' \ | |
https://api.github.com/repos/${{ github.repository }}/pulls) | |
echo "Response for Github API: $response" |