mirror of
https://github.com/github/codeql-action.git
synced 2025-12-31 11:40:24 +08:00
83 lines
2.8 KiB
YAML
83 lines
2.8 KiB
YAML
name: Rebuild Action
|
|
|
|
on:
|
|
pull_request:
|
|
types: [labeled]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
rebuild:
|
|
name: Rebuild Action
|
|
runs-on: ubuntu-latest
|
|
if: github.event.label.name == 'Rebuild'
|
|
|
|
permissions:
|
|
contents: write # needed to push rebuilt commit
|
|
pull-requests: write # needed to comment on the PR
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
- name: Remove label
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
gh pr edit --repo github/codeql-action "$PR_NUMBER" \
|
|
--remove-label "Rebuild"
|
|
|
|
- name: Merge in changes from base branch
|
|
env:
|
|
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
|
|
run: |
|
|
git fetch origin "$BASE_BRANCH"
|
|
|
|
# Allow merge conflicts in `lib`, since rebuilding should resolve them.
|
|
git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected"
|
|
|
|
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
|
|
# since `node_modules/@types/semver/README.md` fails it.
|
|
if git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/'; then
|
|
echo "Merge conflicts detected outside of lib/ directory. Please resolve them manually."
|
|
git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/' || true
|
|
exit 1
|
|
fi
|
|
|
|
- name: Compile TypeScript
|
|
run: |
|
|
npm install
|
|
npm run lint -- --fix
|
|
npm run build
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.11
|
|
|
|
- name: Generate workflows
|
|
run: |
|
|
cd pr-checks
|
|
python -m pip install --upgrade pip
|
|
pip install ruamel.yaml==0.17.31
|
|
python3 sync.py
|
|
|
|
- name: Check for changes and push
|
|
env:
|
|
BRANCH: ${{ github.event.pull_request.head.ref }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
if [ ! -z "$(git status --porcelain)" ]; then
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git config --global user.name "github-actions[bot]"
|
|
git add --all
|
|
git commit -m "Rebuild"
|
|
git push origin "HEAD:$BRANCH"
|
|
echo "Pushed a commit to rebuild the Action." \
|
|
"Please mark the PR as ready for review to trigger PR checks." |
|
|
gh pr comment --body-file - --repo github/codeql-action "$PR_NUMBER"
|
|
gh pr ready --undo --repo github/codeql-action "$PR_NUMBER"
|
|
fi
|