Skip to content

Commit

Permalink
harden the use of third-party GH actions by using explicit SHAs for a…
Browse files Browse the repository at this point in the history
…ny unverified providers
  • Loading branch information
dherman committed May 6, 2024
1 parent 4091edf commit 895361e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
12 changes: 6 additions & 6 deletions pkgs/create-neon/data/templates/ci/github/build.yml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
matrix: {{#$}} steps.matrix.outputs.result {{/$}}
steps:
- name: Checkout Code
uses: actions/checkout@{{versions.actions.checkout}}
uses: actions/checkout@{{versions.actions.verified.checkout}}
with:
ref: {{#$}} inputs.ref {{/$}}
- name: Setup Neon Environment
Expand All @@ -49,7 +49,7 @@ jobs:
run: echo "json=$(npx neon show ci github | jq -rc)" | tee -a $GITHUB_OUTPUT
- name: Compute Matrix
id: matrix
uses: actions/github-script@{{versions.actions.githubScript}}
uses: actions/github-script@{{versions.actions.verified.githubScript}}
with:
script: |
const platforms = {{#$}} steps.matrixData.outputs.json {{/$}};
Expand All @@ -75,7 +75,7 @@ jobs:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@{{versions.actions.checkout}}
uses: actions/checkout@{{versions.actions.verified.checkout}}
with:
ref: {{#$}} inputs.ref {{/$}}
- name: Setup Neon Environment
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
echo filename=$(basename $(npm pack ./platforms/{{#$}} matrix.cfg.platform {{/$}} --silent --pack-destination=./dist --json | jq -r '.[0].filename')) | tee -a $GITHUB_OUTPUT
- name: Release
if: {{#$}} inputs.github-release {{/$}}
uses: softprops/action-gh-release@{{versions.actions.ghRelease}}
uses: softprops/action-gh-release@{{versions.actions.unverified.ghRelease.sha}} # {{versions.actions.unverified.ghRelease.tag}}
with:
files: ./dist/{{#$}} steps.pack.outputs.filename {{/$}}
tag_name: {{#$}} inputs.tag {{/$}}
Expand All @@ -116,7 +116,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@{{versions.actions.checkout}}
uses: actions/checkout@{{versions.actions.verified.checkout}}
with:
ref: {{#$}} inputs.ref {{/$}}
- name: Setup Neon Environment
Expand All @@ -131,7 +131,7 @@ jobs:
echo "filename=$(npm pack --silent --pack-destination=./dist)" | tee -a $GITHUB_OUTPUT
- name: Release
if: {{#$}} inputs.github-release {{/$}}
uses: softprops/action-gh-release@{{versions.actions.ghRelease}}
uses: softprops/action-gh-release@{{versions.actions.unverified.ghRelease.sha}} # {{versions.actions.unverified.ghRelease.tag}}
with:
files: ./dist/{{#$}} steps.pack.outputs.filename {{/$}}
tag_name: {{#$}} inputs.tag {{/$}}
6 changes: 3 additions & 3 deletions pkgs/create-neon/data/templates/ci/github/release.yml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
fi
echo publish=true | tee -a $GITHUB_OUTPUT
- name: Checkout Code
uses: actions/checkout@{{versions.actions.checkout}}
uses: actions/checkout@{{versions.actions.verified.checkout}}
- name: Setup Neon Environment
uses: ./.github/actions/setup
with:
Expand Down Expand Up @@ -112,15 +112,15 @@ jobs:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@{{versions.actions.checkout}}
uses: actions/checkout@{{versions.actions.verified.checkout}}
with:
ref: {{#$}} needs.setup.outputs.ref {{/$}}
- name: Setup Neon Environment
uses: ./.github/actions/setup
with:
use-rust: false
- name: Fetch
uses: robinraju/release-downloader@{{versions.actions.releaseDownloader}}
uses: robinraju/release-downloader@{{versions.actions.unverified.releaseDownloader.sha}} # {{versions.actions.unverified.releaseDownloader.tag}}
with:
tag: {{#$}} needs.setup.outputs.tag {{/$}}
fileName: "*.tgz"
Expand Down
8 changes: 4 additions & 4 deletions pkgs/create-neon/data/templates/ci/github/setup.yml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ runs:
using: "composite"
steps:
- name: Set Environment Variables
uses: falti/dotenv-action@{{versions.actions.dotenv}}
uses: falti/dotenv-action@{{versions.actions.unverified.dotenv.sha}} # {{versions.actions.unverified.dotenv.tag}}
with:
path: ./.github/.env
export-variables: true
keys-case: bypass
- name: Install Node
uses: actions/setup-node@{{versions.actions.setupNode}}
uses: actions/setup-node@{{versions.actions.verified.setupNode}}
with:
node-version: {{#$}} env.NODE_VERSION {{/$}}
registry-url: {{#$}} env.NPM_REGISTRY {{/$}}
Expand All @@ -53,14 +53,14 @@ runs:
working-directory: {{#$}} inputs.workspace {{/$}}
- name: Install Rust
if: {{#$}} inputs['use-rust'] == 'true' {{/$}}
uses: actions-rs/toolchain@{{versions.actions.setupRust}}
uses: actions-rs/toolchain@{{versions.actions.verified.setupRust}}
with:
toolchain: {{#$}} env.RUST_VERSION {{/$}}
target: {{#$}} steps.target.outputs.target {{/$}}
override: true
- name: Install cross-rs
if: {{#$}} inputs['use-cross'] == 'true' {{/$}}
uses: baptiste0928/cargo-install@{{versions.actions.cargoInstall}}
uses: baptiste0928/cargo-install@{{versions.actions.verified.cargoInstall}}
with:
crate: cross
- name: Node Version
Expand Down
2 changes: 1 addition & 1 deletion pkgs/create-neon/data/templates/ci/github/test.yml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@{{versions.actions.checkout}}
uses: actions/checkout@{{versions.actions.verified.checkout}}
- name: Setup Neon Environment
id: neon
uses: ./.github/actions/setup
Expand Down
33 changes: 23 additions & 10 deletions pkgs/create-neon/data/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@
},
"node": "20",
"actions": {
"checkout": "v3",
"githubScript": "v7",
"setupNode": "v3",
"setupRust": "v1",
"cargoInstall": "v2",
"neonBuild": "v0.9",
"neonPublish": "v0.4.1",
"dotenv": "v1",
"ghRelease": "v1",
"releaseDownloader": "v1.7"
"verified": {
"checkout": "v3",
"githubScript": "v7",
"setupNode": "v3",
"setupRust": "v1",
"cargoInstall": "v2",
"neonBuild": "v0.9",
"neonPublish": "v0.4.1"
},
"unverified": {
"dotenv": {
"tag": "v1.1.2",
"sha": "d1cd55661714e830a6e26f608f81d36e23424fed"
},
"ghRelease": {
"tag": "v2.0.4",
"sha": "9d7c94cfd0a1f3ed45544c887983e9fa900f0564"
},
"releaseDownloader": {
"tag": "v1.10",
"sha": "c39a3b234af58f0cf85888573d361fb6fa281534"
}
}
}
}

0 comments on commit 895361e

Please sign in to comment.