chore(ci): Harden Workflows And Pin Actions
This commit is contained in:
@@ -6,6 +6,8 @@ on:
|
|||||||
- opened
|
- opened
|
||||||
- edited
|
- edited
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.issue.number }}
|
group: ${{ github.workflow }}-${{ github.event.issue.number }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -15,15 +17,22 @@ jobs:
|
|||||||
name: Auto Label Issues
|
name: Auto Label Issues
|
||||||
if: ${{ github.event.issue.body && contains(github.event.issue.body, '### Plugin') && contains(github.event.issue.labels.*.name, 'Bug') }}
|
if: ${{ github.event.issue.body && contains(github.event.issue.body, '### Plugin') && contains(github.event.issue.labels.*.name, 'Bug') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
env:
|
||||||
|
ISSUE_BODY: ${{ github.event.issue.body }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Extract Severity From Issue Body
|
- name: Extract Severity From Issue Body
|
||||||
id: extract-severity
|
id: extract-severity
|
||||||
run: |
|
run: |
|
||||||
USER_SELECTED_SEVERITY=$(echo "${{ github.event.issue.body }}" | grep "### Severity" -A 2 | tail -n 1 | sed 's/[[:space:]]*$//')
|
USER_SELECTED_SEVERITY=$(printf '%s\n' "$ISSUE_BODY" | grep "### Severity" -A 2 | tail -n 1 | sed 's/[[:space:]]*$//')
|
||||||
SELECTED_SEVERITY=""
|
SELECTED_SEVERITY=""
|
||||||
|
|
||||||
case "$USER_SELECTED_SEVERITY" in
|
case "$USER_SELECTED_SEVERITY" in
|
||||||
@@ -34,26 +43,26 @@ jobs:
|
|||||||
SELECTED_SEVERITY="Other"
|
SELECTED_SEVERITY="Other"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "SELECTED_SEVERITY=$SELECTED_SEVERITY" >> $GITHUB_ENV
|
echo "SELECTED_SEVERITY=$SELECTED_SEVERITY" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Extract Plugin From Issue Body
|
- name: Extract Plugin From Issue Body
|
||||||
id: parse-issue
|
id: parse-issue
|
||||||
run: |
|
run: |
|
||||||
SELECTED_PLUGIN=$(echo "${{ github.event.issue.body }}" | awk '/### Plugin/ {f=1; next} f && NF {print; exit}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
SELECTED_PLUGIN=$(printf '%s\n' "$ISSUE_BODY" | awk '/### Plugin/ {f=1; next} f && NF {print; exit}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
|
||||||
echo "SELECTED_PLUGIN=$SELECTED_PLUGIN" >> $GITHUB_ENV
|
echo "SELECTED_PLUGIN=$SELECTED_PLUGIN" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Extract Language From Issue Body
|
- name: Extract Language From Issue Body
|
||||||
id: extract-language
|
id: extract-language
|
||||||
run: |
|
run: |
|
||||||
SELECTED_LANGUAGE=$(echo "${{ github.event.issue.body }}" | awk '/### Language/ {f=1; next} f && NF {print; exit}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
SELECTED_LANGUAGE=$(printf '%s\n' "$ISSUE_BODY" | awk '/### Language/ {f=1; next} f && NF {print; exit}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
|
||||||
echo "SELECTED_LANGUAGE=$SELECTED_LANGUAGE" >> $GITHUB_ENV
|
echo "SELECTED_LANGUAGE=$SELECTED_LANGUAGE" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Determine Corresponding Label
|
- name: Determine Corresponding Label
|
||||||
id: determine-label
|
id: determine-label
|
||||||
run: |
|
run: |
|
||||||
LABELS="$( jq --arg keys "${{ env.SELECTED_PLUGIN }}" '. as $data | $keys | split(", ") as $keyList | $keyList[] | . as $key | if $data[$key] != null then "\($key)[\($data[$key])]" else empty end' ./.github/scripts/keys.json | sed 's/"//g' | sed 's/^[^:]*: //' )"
|
LABELS="$(jq --arg keys "$SELECTED_PLUGIN" '. as $data | $keys | split(", ") as $keyList | $keyList[] | . as $key | if $data[$key] != null then "\($key)[\($data[$key])]" else empty end' ./.github/scripts/keys.json | sed 's/"//g' | sed 's/^[^:]*: //')"
|
||||||
|
|
||||||
# Add "Plugin: " in front of each label
|
# Add "Plugin: " in front of each label
|
||||||
LABELS_WITH_PREFIX="$(echo "$LABELS" | sed 's/^/Plugin: /')"
|
LABELS_WITH_PREFIX="$(echo "$LABELS" | sed 's/^/Plugin: /')"
|
||||||
@@ -65,15 +74,20 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Save to GitHub environment
|
# Save to GitHub environment
|
||||||
printf "LABELS<<EOF\n%s\nEOF\n" "$FINAL_LABELS" >> $GITHUB_ENV
|
printf "LABELS<<EOF\n%s\nEOF\n" "$FINAL_LABELS" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Add Labels To Issue
|
- name: Add Labels To Issue
|
||||||
if: env.LABELS != ''
|
if: env.LABELS != ''
|
||||||
uses: actions-ecosystem/action-add-labels@v1
|
env:
|
||||||
with:
|
GH_TOKEN: ${{ github.token }}
|
||||||
labels: |
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||||
Severity: ${{ env.SELECTED_SEVERITY }}
|
REPOSITORY: ${{ github.repository }}
|
||||||
${{ env.LABELS }}
|
run: |
|
||||||
|
jq -n \
|
||||||
|
--arg severity "$SELECTED_SEVERITY" \
|
||||||
|
--arg labels "$LABELS" \
|
||||||
|
'{labels: (["Severity: " + $severity] + ($labels | split("\n") | map(select(length > 0))))}' \
|
||||||
|
| gh api --method POST "repos/$REPOSITORY/issues/$ISSUE_NUMBER/labels" --input -
|
||||||
|
|
||||||
- name: Handle Missing Label
|
- name: Handle Missing Label
|
||||||
if: env.LABELS == ''
|
if: env.LABELS == ''
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ on:
|
|||||||
- cron: '0 0 * * *'
|
- cron: '0 0 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}
|
group: ${{ github.workflow }}
|
||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
@@ -13,10 +15,13 @@ jobs:
|
|||||||
lock:
|
lock:
|
||||||
name: Lock Inactive Threads
|
name: Lock Inactive Threads
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Lock Inactive Issues And Pull Requests
|
- name: Lock Inactive Issues And Pull Requests
|
||||||
uses: dessant/lock-threads@v5
|
uses: dessant/lock-threads@89ae32b08ed1a541efecbab17912962a5e38981c # v6.0.2
|
||||||
with:
|
with:
|
||||||
github-token: ${{ github.token }}
|
github-token: ${{ github.token }}
|
||||||
issue-lock-inactive-days: '2'
|
issue-inactive-days: '2'
|
||||||
pr-lock-inactive-days: '2'
|
pr-inactive-days: '2'
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -15,19 +18,14 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '24'
|
||||||
|
|
||||||
- name: Install Prettier
|
|
||||||
run: |
|
|
||||||
rm package.json
|
|
||||||
rm package-lock.json
|
|
||||||
npm init -y
|
|
||||||
npm install prettier@3.2.5
|
|
||||||
|
|
||||||
- name: Check Code Formatting
|
- name: Check Code Formatting
|
||||||
run: npx prettier --check "./src/**/*.{ts,tsx,js,css}"
|
run: npx --yes prettier@3.2.5 --check "./src/**/*.{ts,tsx,js,css}"
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ on:
|
|||||||
- 'scripts/publish-plugins.sh'
|
- 'scripts/publish-plugins.sh'
|
||||||
- '.github/workflows/publish-plugins.yml'
|
- '.github/workflows/publish-plugins.yml'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}
|
group: ${{ github.workflow }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -20,17 +23,17 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.REPO_SCOPED_TOKEN }}
|
token: ${{ secrets.REPO_SCOPED_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '24'
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm install --omit=dev --ignore-scripts
|
run: npm ci --omit=dev --ignore-scripts
|
||||||
|
|
||||||
- name: Configure Git
|
- name: Configure Git
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ on:
|
|||||||
issues:
|
issues:
|
||||||
types: [labeled]
|
types: [labeled]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.issue.number }}
|
group: ${{ github.workflow }}-${{ github.event.issue.number }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|||||||
@@ -26,20 +26,20 @@ jobs:
|
|||||||
github.event.workflow_run.event == 'push'
|
github.event.workflow_run.event == 'push'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
ref: master
|
ref: master
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '24'
|
||||||
|
|
||||||
- name: Generate Issue Template Options
|
- name: Generate Issue Template Options
|
||||||
run: node ./.github/scripts/generate-issue-template-options.cjs
|
run: node ./.github/scripts/generate-issue-template-options.cjs
|
||||||
|
|
||||||
- name: Create Or Update Pull Request
|
- name: Create Or Update Pull Request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||||
with:
|
with:
|
||||||
commit-message: 'chore: Update Issue Template Plugin Options [skip ci]'
|
commit-message: 'chore: Update Issue Template Plugin Options [skip ci]'
|
||||||
branch: 'update-issue-template'
|
branch: 'update-issue-template'
|
||||||
|
|||||||
Reference in New Issue
Block a user