Skip to content

Ignore netlify.toml #149

Ignore netlify.toml

Ignore netlify.toml #149

Workflow file for this run

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')