-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (94 loc) · 4.26 KB
/
bump-gluon.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# yamllint disable rule:line-length
---
name: "Update the Gluon base"
# yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
site-branch:
description: "Site branch to update"
required: true
default: "main"
gluon-commit:
description: "Gluon commit to update to"
required: true
default: "HEAD"
skip-pull-request:
description: "Skip pull request creation"
type: boolean
required: true
default: true
jobs:
update-gluon:
runs-on: ubuntu-latest
env:
GLUON_CHECKOUT_DIR: /tmp/gluon
COMMIT_MESSAGE_PATH: /tmp/commit-message.txt
BUILD_INFO: .github/build-info.json
BUILD_INFO_TMP: .github/build-info.json.tmp
COMMIT_NAME: GitHub Actions
COMMIT_EMAIL: [email protected]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.site-branch }}
- name: Clone Gluon
run: |
REPO=$(jq -r '.gluon.repository' $BUILD_INFO)
git clone https://github.com/${REPO}.git /tmp/gluon
- name: Checkout Gluon branch
run: git -C $GLUON_CHECKOUT_DIR checkout "$(jq -r '.gluon.branch' $BUILD_INFO)"
- name: Get commit hash
id: head-hash
run: |
BUILD_HASH="$(git -C $GLUON_CHECKOUT_DIR rev-parse ${{ github.event.inputs.gluon-commit }})"
echo "hash=$(git -C $GLUON_CHECKOUT_DIR rev-parse "$BUILD_HASH")" >> "$GITHUB_OUTPUT"
echo "short-hash=$(git -C $GLUON_CHECKOUT_DIR rev-parse --short "$BUILD_HASH")" >> "$GITHUB_OUTPUT"
- name: Get build-info.json commit hash
id: build-info-hash
run: |
BUILD_HASH="$(jq -r '.gluon.commit' $BUILD_INFO)"
echo "hash=$(git -C $GLUON_CHECKOUT_DIR rev-parse "$BUILD_HASH")" >> "$GITHUB_OUTPUT"
echo "short-hash=$(git -C $GLUON_CHECKOUT_DIR rev-parse --short "$BUILD_HASH")" >> "$GITHUB_OUTPUT"
- name: Update commit-hash
if: steps.head-hash.outputs.hash != steps.build-info-hash.outputs.hash
run: >-
jq --arg commit_hash "${{ steps.head-hash.outputs.hash }}"
--indent 4
'.gluon.commit = $commit_hash'
$BUILD_INFO > $BUILD_INFO_TMP
- name: Update build-info.json
if: steps.head-hash.outputs.hash != steps.build-info-hash.outputs.hash
run: mv $BUILD_INFO_TMP $BUILD_INFO
- name: Generate commit message
if: steps.head-hash.outputs.hash != steps.build-info-hash.outputs.hash
id: commit-message
run: |
echo "msg<<EOF" >> "$GITHUB_OUTPUT"
./.github/bump-gluon-commit-message.sh $GLUON_CHECKOUT_DIR ${{ steps.build-info-hash.outputs.hash }} ${{ steps.head-hash.outputs.hash }} >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Commit and push changes
if: steps.head-hash.outputs.hash != steps.build-info-hash.outputs.hash
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ${{ steps.commit-message.outputs.msg }}
commit_options: '--no-verify --signoff'
commit_user_name: ${{ env.COMMIT_NAME }}
commit_user_email: ${{ env.COMMIT_EMAIL }}
commit_author: ${{ env.COMMIT_NAME }} <${{ env.COMMIT_EMAIL }}>
branch: bump-gluon-${{ github.event.inputs.site-branch }}-${{ steps.head-hash.outputs.short-hash }}
create_branch: true
- name: Create pull request
if: steps.head-hash.outputs.hash != steps.build-info-hash.outputs.hash && github.event.inputs.skip-pull-request == 'false'
run: >-
gh pr create
-B ${{ github.event.inputs.site-branch }}
-H bump-gluon-${{ github.event.inputs.site-branch }}-${{ steps.head-hash.outputs.short-hash }}
--fill
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Emit PR creation message
if: steps.head-hash.outputs.hash != steps.build-info-hash.outputs.hash && github.event.inputs.skip-pull-request == 'true'
run:
echo "::notice::Create pull-request at https://github.com/${{ github.repository }}/compare/${{ github.event.inputs.site-branch }}...bump-gluon-${{ github.event.inputs.site-branch }}-${{ steps.head-hash.outputs.short-hash }}?quick_pull=1"