Skip to content

Commit 4659456

Browse files
lwjohnst86signekbpre-commit-ci[bot]
authored
refactor: 👷 replace reusable workflows with normal workflow steps (#284)
# Description Reusable workflows are harder to check from a security scanning perspective. They are also harder to modify for specific needs of the repo. So this moves all the steps from the reusable workflows into this template. Needs a quick review. ## Checklist - [x] Ran `just run-all` --------- Co-authored-by: Signe Kirk Brødbæk <40836345+signekb@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 704b0ea commit 4659456

11 files changed

Lines changed: 321 additions & 80 deletions

File tree

.github/workflows/add-to-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
# This is a useful security step to check for unexpected outbound calls from the runner,
2727
# which could indicate a compromised token or runner.
2828
- name: Harden the runner (Audit all outbound calls)
29-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
29+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
3030
with:
3131
egress-policy: audit
3232

.github/workflows/build-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
# This is a useful security step to check for unexpected outbound calls from the runner,
2222
# which could indicate a compromised token or runner.
2323
- name: Harden the runner (Audit all outbound calls)
24-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
24+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
2525
with:
2626
egress-policy: audit
2727

.github/workflows/checks.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
# This is a useful security step to check for unexpected outbound calls from the runner,
1212
# which could indicate a compromised token or runner.
1313
- name: Harden the runner (Audit all outbound calls)
14-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
14+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
1515
with:
1616
egress-policy: audit
1717

@@ -41,7 +41,7 @@ jobs:
4141
# This is a useful security step to check for unexpected outbound calls from the runner,
4242
# which could indicate a compromised token or runner.
4343
- name: Harden the runner (Audit all outbound calls)
44-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
44+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
4545
with:
4646
egress-policy: audit
4747

@@ -57,7 +57,7 @@ jobs:
5757
# This is a useful security step to check for unexpected outbound calls from the runner,
5858
# which could indicate a compromised token or runner.
5959
- name: Harden the runner (Audit all outbound calls)
60-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
60+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
6161
with:
6262
egress-policy: audit
6363

@@ -83,7 +83,7 @@ jobs:
8383
runs-on: ubuntu-latest
8484
steps:
8585
- name: Harden the runner (Audit all outbound calls)
86-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
86+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
8787
with:
8888
egress-policy: audit
8989

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
# This is a useful security step to check for unexpected outbound calls from the runner,
2525
# which could indicate a compromised token or runner.
2626
- name: Harden the runner (Audit all outbound calls)
27-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
27+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
2828
with:
2929
egress-policy: audit
3030

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Add to project board
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
- reopened
8+
- transferred
9+
pull_request:
10+
types:
11+
- reopened
12+
- opened
13+
14+
# Limit token permissions for security
15+
permissions: read-all
16+
17+
env:
18+
# TODO: Add the correct board number for this repo.
19+
BOARD_NUMBER: ""
20+
21+
jobs:
22+
add-to-project:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
pull-requests: write
26+
steps:
27+
# This is a useful security step to check for unexpected outbound calls from the runner,
28+
# which could indicate a compromised token or runner.
29+
- name: Harden the runner (Audit all outbound calls)
30+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
31+
with:
32+
egress-policy: audit
33+
34+
# Using this security pattern for GitHub Apps is recommended by GitHub and ensures that
35+
# the token is only available for a short time and has limited permissions. Check out
36+
# <https://guidebook.seedcase-project.org/operations/security> for more details.
37+
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
38+
id: app-token
39+
with:
40+
# TODO: Confirm that this variable is set up for this repo.
41+
client-id: "${{ vars.ADD_TO_BOARD_APP_ID }}"
42+
# TODO: Confirm that this secret is set up for this repo.
43+
private-key: "${{ secrets.ADD_TO_BOARD }}"
44+
45+
- name: Add issue or PR to project board
46+
uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
47+
with:
48+
project-url: "https://github.com/orgs/${{ github.repository_owner }}/projects/${{ env.BOARD_NUMBER }}"
49+
github-token: "${{ steps.app-token.outputs.token }}"
50+
51+
- name: Assign PR to creator
52+
if: ${{ github.event_name == 'pull_request' }}
53+
run: |
54+
gh pr edit $PR --add-assignee $AUTHOR --repo $REPO
55+
env:
56+
REPO: ${{ github.repository }}
57+
AUTHOR: ${{ github.event.pull_request.user.login }}
58+
PR: ${{ github.event.pull_request.html_url }}
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

template/.github/workflows/add-to-project.yml.jinja

Lines changed: 0 additions & 28 deletions
This file was deleted.

template/.github/workflows/build-website.yml.jinja

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,73 @@ permissions: read-all
1010

1111
jobs:
1212
build-website:
13-
uses: seedcase-project/.github/.github/workflows/reusable-build-docs-with-python.yml@main
13+
runs-on: ubuntu-latest
1414
{%- if hosting_provider == 'gh-pages' %}
1515
with:
1616
hosting-provider: gh-pages
1717
permissions:
1818
contents: write
1919
pages: write
2020
{%- endif %}
21-
secrets:
22-
{% if hosting_provider == 'gh-pages' -%}
23-
github-token: {{ '${{ secrets.GITHUB_TOKEN }}' }}
24-
{%- elif hosting_provider == 'netlify' -%}
25-
netlify-token: {{ '${{ secrets.NETLIFY_AUTH_TOKEN }}' }}
21+
concurrency:
22+
group: build-website-python-group
23+
cancel-in-progress: true
24+
env:
25+
QUARTO_PYTHON: ".venv/bin/python3"
26+
steps:
27+
- name: Harden the runner (Audit all outbound calls)
28+
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
29+
with:
30+
egress-policy: audit
31+
32+
- name: Check out repository
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
37+
with:
38+
# Install a specific version of uv.
39+
# uv recommends to set the version for best practice.
40+
version: "0.11.15"
41+
# To have a faster CI time, enable cache between runs.
42+
enable-cache: true
43+
# Reset the cache if the lock file changes.
44+
cache-dependency-glob: "uv.lock"
45+
46+
- name: "Set up Python"
47+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
48+
with:
49+
python-version-file: "pyproject.toml"
50+
51+
- name: Install the project and it's dependencies
52+
run: |
53+
uv sync --all-extras --dev
54+
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
55+
56+
- name: Set up Quarto
57+
uses: quarto-dev/quarto-actions/setup@8a96df13519ee81fd526f2dfca5962811136661b # v2.2.0
58+
59+
- name: Spell check repo
60+
uses: crate-ci/typos@aca895bf05aec0cb7dffa6f94495e923224d9f17 # v1.46.2
61+
62+
- name: Build function reference docs
63+
run: uv run quartodoc build
64+
65+
{% if hosting_provider == 'netlify' -%}
66+
- name: Publish to Netlify (and render)
67+
if: {{ "${{ inputs.hosting-provider == 'netlify' }}" }}
68+
uses: quarto-dev/quarto-actions/publish@8a96df13519ee81fd526f2dfca5962811136661b # v2.2.0
69+
with:
70+
target: netlify
71+
NETLIFY_AUTH_TOKEN: {{ '${{ secrets.netlify-token }}' }}
72+
73+
{%- elif hosting_provider == 'gh-pages' -%}
74+
# NOTE: If Publishing to GitHub Pages, set the permissions correctly (see above).
75+
- name: Publish to GitHub Pages (and render)
76+
if: {{ "${{ inputs.hosting-provider == 'gh-pages' }}" }}
77+
uses: quarto-dev/quarto-actions/publish@8a96df13519ee81fd526f2dfca5962811136661b # v2.2.0
78+
with:
79+
target: gh-pages
80+
env:
81+
GITHUB_TOKEN: {{ '${{ secrets.github-token }}' }}
2682
{%- endif %}

template/.github/workflows/check-package.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)