Skip to content

Commit 65988f4

Browse files
committed
Actions: Add workflow to fast-forward tracking branch for latest CodeQL release
1 parent 4a11ae9 commit 65988f4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/fast-forward.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Fast-forward tracking branch for latest CodeQL version
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
fast-forward:
7+
name: Fast-forward tracking branch for latest CodeQL version
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'github/codeql'
10+
permissions:
11+
contents: write
12+
env:
13+
BRANCH_NAME: 'lgtm.com'
14+
steps:
15+
- name: Validate chosen branch
16+
if: ${{ !startsWith(github.ref_name, 'codeql-cli-') }}
17+
shell: bash
18+
run: |
19+
echo "::error ::The $BRANCH_NAME tracking branch should only be fast-forwarded to the tip of a codeql-cli-* branch, got $GITHUB_REF instead."
20+
exit 1
21+
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Git config
26+
shell: bash
27+
run: |
28+
git config user.name "github-actions[bot]"
29+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
30+
31+
- name: Fetch
32+
shell: bash
33+
run: |
34+
set -x
35+
echo "Fetching $BRANCH_NAME"
36+
# Explicitly unshallow and fetch to ensure the remote ref is available.
37+
git fetch --unshallow origin "$BRANCH_NAME"
38+
git checkout -b "$BRANCH_NAME" "origin/$BRANCH_NAME"
39+
40+
- name: Fast-forward
41+
shell: bash
42+
run: |
43+
echo "Fast-forwarding $BRANCH_NAME to ${GITHUB_REF}@${GITHUB_SHA}"
44+
git merge --ff-only "$GITHUB_SHA"
45+
git push origin "$BRANCH_NAME"

0 commit comments

Comments
 (0)