mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-04-28 14:24:37 +00:00
Harden Dependabot build workflow
This commit is contained in:
parent
5ba8a7e5d0
commit
74929ea542
1 changed files with 35 additions and 7 deletions
42
.github/workflows/dependabot-build.yml
vendored
42
.github/workflows/dependabot-build.yml
vendored
|
|
@ -4,18 +4,26 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event.pull_request.user.login == 'dependabot[bot]'
|
if: >-
|
||||||
|
github.event.pull_request.user.login == 'dependabot[bot]' &&
|
||||||
|
github.event.pull_request.head.repo.full_name == github.repository &&
|
||||||
|
startsWith(github.head_ref, 'dependabot/')
|
||||||
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout PR branch
|
- name: Checkout PR branch
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
|
|
@ -25,15 +33,35 @@ jobs:
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci --ignore-scripts
|
||||||
|
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: npm run all
|
run: npm run all
|
||||||
|
|
||||||
- name: Commit built dist
|
- name: Commit built dist
|
||||||
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5
|
|
||||||
env:
|
env:
|
||||||
|
EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
run: |
|
||||||
commit_message: "Build dist for Dependabot update"
|
git config user.name "github-actions[bot]"
|
||||||
file_pattern: dist/
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local core.hooksPath /dev/null
|
||||||
|
|
||||||
|
git fetch --no-tags --depth=1 origin "${GITHUB_HEAD_REF}"
|
||||||
|
if [ "$(git rev-parse FETCH_HEAD)" != "${EXPECTED_HEAD_SHA}" ]; then
|
||||||
|
echo "::notice::Skipping dist commit because ${GITHUB_HEAD_REF} moved after the workflow started."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git add --all dist/
|
||||||
|
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "No dist changes to commit."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git commit -m "Build dist for Dependabot update"
|
||||||
|
|
||||||
|
auth="$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 | tr -d '\n')"
|
||||||
|
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic ${auth}" \
|
||||||
|
push origin "HEAD:${GITHUB_HEAD_REF}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue