Skip to content

Commit e2cb209

Browse files
authored
Merge pull request github#12771 from adityasharad/actions/fast-forward
Actions: Add workflow to fast-forward tracking branch for latest CodeQL release
2 parents c879863 + ad8d4ac commit e2cb209

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/fast-forward.yml

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

0 commit comments

Comments
 (0)