-
Notifications
You must be signed in to change notification settings - Fork 16
70 lines (59 loc) · 2.35 KB
/
issues.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: issue created
on:
issues:
types: [edited, opened]
jobs:
add_fact:
name: add a new fact if appropriate
runs-on: ubuntu-latest
steps:
# Rather than use a personal access token to interact with the project, we
# can use this GitHub App. There's an API for exchanging app credentials
# for a short-term token, and we use that API here.
- name: get token
uses: tibdex/github-app-token@v1
id: app_token
with:
app_id: ${{ secrets.APP_ID }}
installation_id: ${{ secrets.APP_INSTALLATION_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.app_token.outputs.token }}
ref: main
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: install dependencies
run: npm install --production
- name: update files with new fact
run: node addFact.js
working-directory: ./.github/workflows
- name: check for changes
run: if git diff --exit-code --quiet; then echo "::set-output name=changes::no"; else echo "::set-output name=changes::yes"; fi
id: diff
# If anything changed, commit it.
- name: change branches
if: steps.diff.outputs.changes == 'yes'
run: git checkout -b add-fact/${{ github.event.issue.number }}
- name: commit changes
if: steps.diff.outputs.changes == 'yes'
uses: EndBug/add-and-commit@v9
with:
message: "adding fact; closes #${{ github.event.issue.number }}"
# Force push because if this issue has been edited, then there's
# already a branch with this name, but it refers to the prior edit so
# we'll just... throw it away.
push: "origin add-fact/${{ github.event.issue.number }} --force"
- name: open pull request
if: steps.diff.outputs.changes == 'yes'
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
NUM=${{ github.event.issue.number }}
BRANCH="add-fact/${{ github.event.issue.number }}"
gh pr create \
--title "Adding fact for #$NUM" \
--body "This fact is being added automatically from the contents of #$NUM. Closes #$NUM."
gh pr merge $BRANCH --auto --squash