Skip to content

Instantly share code, notes, and snippets.

@autonome
Created June 28, 2024 09:17
Show Gist options
  • Save autonome/07fa93a087d3572e3c2c338855bfbedb to your computer and use it in GitHub Desktop.
Save autonome/07fa93a087d3572e3c2c338855bfbedb to your computer and use it in GitHub Desktop.
Airtable2PullRequest
name: Airtable2PullRequest
on:
workflow_dispatch:
repository_dispatch:
types:
- webhook
permissions:
contents: write
jobs:
checkout-update-and-pr:
runs-on: ubuntu-latest
environment: Actions
permissions: write-all
steps:
- uses: actions/checkout@v3
- run: |
echo ${{ github.repository }}
# delete remote branch from prev run if exists
(git push origin -d airtable-import || true)
# checkout new branch for pr
git checkout main -b airtable-import
# run script which pulls all data, formats it, writes changes to local checkout
AIRTABLE_TOKEN=${{ vars.AIRTABLE_TOKEN }} node scripts/airtable-import.js
# pick up any new files
git add content/tracks/*.md
# gha needs a user to do any writes
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions"
# commit and push to new remote branch
git commit -a -m "Airtable import"
git push origin airtable-import
# make a pr, et viola
gh pr create -B main -H airtable-import -R ${{ github.repository }} --title 'Merge airtable import' --body 'Created by Github action, see .github/workflows/main.yml'
env:
GH_TOKEN: ${{ github.token }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment