Tokens Please #12
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: Dispatch Token Request | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
distribute-tokens: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
- name: Fetch Opened Issue | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
issue_number=${{ github.event.issue.number }} | |
issue_body="${{ github.event.issue.body }}" | |
issue_author="${{ github.event.issue.user.id }}" | |
issue_json=$(jq -n \ | |
--arg number "$issue_number" \ | |
--arg body "$issue_body" \ | |
--arg author "$issue_author" \ | |
'{number: $number, body: $body, author: $author}') | |
echo "$issue_json" > opened_issue.json | |
echo "Fetched issue details: $issue_json" | |
- name: Install Deps | |
run: npm install | |
- name: Process Request | |
env: | |
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
run: npm start | |
- name: Close the Issue | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
issue_number=${{ github.event.issue.number }} | |
gh issue close "$issue_number" --reason "completed" | |
echo "Closed issue #$issue_number" | |
- name: Rename and Upload the JSON File | |
if: ${{ hashFiles('requests.json') != '' }} | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
git add requests.json | |
git commit -m "Update requests.json" | |
git push |