-
Notifications
You must be signed in to change notification settings - Fork 603
86 lines (81 loc) · 3.3 KB
/
sync-kuma-submodule.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
name: Sync Kuma submodule
# Ensure that we only run 1 workflow per branch at a time (cancel if one is already running).
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}
on:
workflow_dispatch:
inputs: {}
repository_dispatch:
types: [UPDATE_SUBMODULE]
pull_request:
types: [closed]
schedule:
- cron: '0 0 * * *'
jobs:
get-current-do-not-close-pr:
name: 'Get current do-not-close PR'
timeout-minutes: 10
# Runs for the two dispatch triggers. Also runs for merged pull requests **if** they have the “do-not-close” label.
if: github.event_name != 'pull_request' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'do-not-close'))
runs-on: ubuntu-latest
outputs:
number: ${{ steps.get-current-pr.outputs.number }}
steps:
- name: 'Get current do-not-close PR'
id: get-current-pr
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
number=`gh pr list --repo ${{ github.repository }} -l do-not-close -B main --json number --jq '.[0].number'`
echo number=$number >> $GITHUB_OUTPUT
update-submodule:
name: 'Update submodule'
timeout-minutes: 10
needs: get-current-do-not-close-pr
if: ${{ ! needs.get-current-do-not-close-pr.outputs.number }} # Do not overwrite the PR if there's a do-not-close label
runs-on: ubuntu-latest
steps:
- name: 'Check-out current repo'
uses: actions/checkout@v4
with:
submodules: true
ref: main
# In order to update the submodule, we need unlimited fetch-depth.
fetch-depth: 0
- name: 'Get current repo data'
working-directory: app/_src/.repos/kuma
run: |
echo SUBMODULE_OLD_SHA=`git log -1 --format=format:%h` >> $GITHUB_ENV
- name: 'Update submodule'
run: |
git submodule update --remote app/_src/.repos/kuma
- name: 'Get submodule repo data'
working-directory: app/_src/.repos/kuma
run: |
echo SUBMODULE_NEW_SHA=`git log -1 --format=format:%h` >> $GITHUB_ENV
echo "SUBMODULE_PR_LOG<<EOF" >> $GITHUB_ENV
git log ${{ env.SUBMODULE_OLD_SHA }}..HEAD --format=oneline -- | sed -E 's:(#[0-9]+):kumahq/kuma-website\1:g' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: 'Create pull request'
# https://github.com/peter-evans/create-pull-request
uses: peter-evans/create-pull-request@v6
id: newPR
with:
base: main
commit-message: 'chore(deps): bump kumahq/kuma-website from ${{ env.SUBMODULE_OLD_SHA }} to ${{ env.SUBMODULE_NEW_SHA }}'
committer: kong-docs[bot] <[email protected]>
author: kong-docs[bot] <[email protected]>
signoff: true
branch: chore/upgrade-kuma-website
token: ${{ secrets.PAT }}
delete-branch: true
labels: |
skip-changelog
review:general
title: 'chore(deps): bump kumahq/kuma-website from ${{ env.SUBMODULE_OLD_SHA }} to ${{ env.SUBMODULE_NEW_SHA }}'
body: |
Auto upgrade PR log:
${{ env.SUBMODULE_PR_LOG }}
Triggered by [action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
draft: false