merge(#9): chore: save token to file #8
This file contains hidden or 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: Update AUTHORS.md on merge | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: yarn install | |
- name: Run authors | |
run: yarn authors | |
- name: Check if AUTHORS.md has changed | |
run: | | |
if git status --porcelain | grep 'AUTHORS.md'; then | |
echo "CHANGED=true" >> $GITHUB_ENV | |
else | |
echo "CHANGED=false" >> $GITHUB_ENV | |
fi | |
echo "CHANGED is $CHANGED" | |
- name: Create and push a PR | |
if: env.CHANGED == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "chore: update AUTHORS.md" | |
title: "chore: update AUTHORS.md" | |
body: "This PR updates the AUTHORS.md file." | |
branch: feat/update-authors-md | |
base: main | |
- name: Login and merge PR with gh | |
if: env.CHANGED == 'true' | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} > token.txt | |
gh auth login --with-token < token.txt | |
gh pr merge --auto --squash --delete-branch |