-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (144 loc) · 5.57 KB
/
push.yml
File metadata and controls
161 lines (144 loc) · 5.57 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: On Push
on:
push:
branches: main
pull_request:
branches: main
jobs:
commit_author:
name: Get Commit Author
runs-on: ubuntu-latest
outputs:
name: ${{ steps.author.outputs.name }}
email: ${{ steps.author.outputs.email }}
name_addr: ${{ format('{0} <{1}>', steps.author.outputs.name, steps.author.outputs.email) }}
steps:
- name: Get author
id: author
env:
GH_TOKEN: ${{ github.token }}
run: |
name='buxbot[bot]'
id=$(gh api "/users/$name" -q .id)
echo "name=$name" >> $GITHUB_OUTPUT
echo "email=$id+$name@users.noreply.github.com" >> $GITHUB_OUTPUT
build_assets:
name: Build CV Assets
runs-on: ubuntu-latest
needs: commit_author
steps:
- name: Generate a token
if: ${{ github.event_name == 'push' }}
id: token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.BUXBOT_APP_ID }}
private-key: ${{ secrets.BUXBOT_PRIVATE_KEY }}
- name: Checkout repo
uses: actions/checkout@v6
with:
# to ensure page_build workflow executes. Fallback for dependabot
token: ${{ steps.token.outputs.token || github.token }}
- name: Install LaTeX packages
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-base texlive-latex-recommended texlive-latex-extra aspell aspell-en
- name: Build assets
run: make
- name: Spell check
run: make spell
- name: Commit assets
if: ${{ github.event_name == 'push' }}
uses: stefanzweifel/git-auto-commit-action@v7
with:
add_options: --force
file_pattern: chris-buckley-cv.pdf index.md
skip_dirty_check: true
skip_checkout: true
commit_user_name: ${{ needs.commit_author.outputs.name }}
commit_user_email: ${{ needs.commit_author.outputs.email }}
commit_author: ${{ needs.commit_author.outputs.name_addr }}
commit_message: Updated GitHub Pages
branch: gh-pages
push_options: --force
check_role:
name: Check Role
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.check.outputs.changed }}
role: ${{ steps.details.outputs.role }}
company: ${{ steps.details.outputs.company }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Get current role and location
id: details
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "existing=$(gh api users/${{ github.repository_owner }} -q .bio)" >> $GITHUB_OUTPUT
echo "role=$(awk -v col=role -f _src/role.awk _src/cv.tex)" >> $GITHUB_OUTPUT
echo "company=$(awk -v col=company -f _src/role.awk _src/cv.tex)" >> $GITHUB_OUTPUT
- name: Compare roles
id: check
run: |
echo "Current: ${{ steps.details.outputs.existing }}"
if [ -n "${{ steps.details.outputs.role }}" ]; then
echo "New: ${{ format('{0} at {1}', steps.details.outputs.role, steps.details.outputs.company) }}"
echo "changed=${{ toJSON(steps.details.outputs.existing != format('{0} at {1}', steps.details.outputs.role, steps.details.outputs.company)) }}" >> $GITHUB_OUTPUT
else
echo "No current role, not updating bio"
echo "changed=false" >> $GITHUB_OUTPUT
fi
update_role:
name: Update Role
runs-on: ubuntu-latest
needs: [commit_author, check_role]
if: ${{ github.event_name == 'push' && fromJSON(needs.check_role.outputs.changed) }}
steps:
- name: Generate a token
id: token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.BUXBOT_APP_ID }}
private-key: ${{ secrets.BUXBOT_PRIVATE_KEY }}
repositories: ${{ github.repository_owner }}.github.io
- name: Update GitHub bio
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: gh api -X PATCH user -F "bio=${{ format('{0} at {1}', needs.check_role.outputs.role, needs.check_role.outputs.company) }}"
- name: Checkout main site repo
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/${{ github.repository_owner }}.github.io
token: ${{ steps.token.outputs.token }}
path: ${{ github.workspace }}/site
- name: Update role
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'role:.*'
replace: 'role: ${{ needs.check_role.outputs.role }}'
include: site/_config.yml
- name: Update company
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'company:.*'
replace: 'company: ${{ needs.check_role.outputs.company }}'
include: site/_config.yml
- name: Create Pull Request
id: pull-request
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.token.outputs.token }}
path: ${{ github.workspace }}/site
branch: role-${{ github.run_id }}
author: ${{ needs.commit_author.outputs.name_addr }}
committer: ${{ needs.commit_author.outputs.name_addr }}
commit-message: Update role from CV
title: Update role from CV
body: 'Updates role to match CV repository. See full diff: ${{ github.event.compare }}'
- name: Check Pull Request
if: steps.pull-request.outputs.pull-request-operation == ''
uses: actions/github-script@v8
with:
script: core.setFailed('No Pull Request was created')