-
Notifications
You must be signed in to change notification settings - Fork 17
79 lines (69 loc) · 2.92 KB
/
update-submodules.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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2011-2022 ETH Zurich.
name: Update Submodules
on:
workflow_dispatch: # allow to manually trigger this workflow
schedule:
- cron: '0 6 * * *' # run every day at 06:00 UTC
jobs:
# Update the submodules and create a PR if there are any changes
update:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: true
- name: Get current commits
run: |
echo "PREV_SILICON_REF=$(git -C silicon rev-parse HEAD)" >> $GITHUB_ENV
echo "PREV_CARBON_REF=$(git -C carbon rev-parse HEAD)" >> $GITHUB_ENV
- name: Update Silicon submodule
run: git checkout master && git pull
working-directory: silicon
- name: Update Carbon submodule
run: git checkout master && git pull
working-directory: carbon
- name: Get new commits
run: |
echo "CUR_SILICON_REF=$(git -C silicon rev-parse HEAD)" >> $GITHUB_ENV
echo "CUR_CARBON_REF=$(git -C carbon rev-parse HEAD)" >> $GITHUB_ENV
- name: Create PR body
run: |
if [[ "${{ env.PREV_SILICON_REF }}" != "${{ env.CUR_SILICON_REF }}" ]]; then
echo 'PR_BODY_LINE1=* Updates Silicon from `${{ env.PREV_SILICON_REF }}` to `${{ env.CUR_SILICON_REF }}`.' >> $GITHUB_ENV
else
echo 'PR_BODY_LINE1=' >> $GITHUB_ENV
fi
if [[ "${{ env.PREV_CARBON_REF }}" != "${{ env.CUR_CARBON_REF }}" ]]; then
echo 'PR_BODY_LINE2=* Updates Carbon from `${{ env.PREV_CARBON_REF }}` to `${{ env.CUR_CARBON_REF }}`.' >> $GITHUB_ENV
else
echo 'PR_BODY_LINE2=' >> $GITHUB_ENV
fi
- name: Open a pull request
id: pr
uses: peter-evans/create-pull-request@v4
if: (env.PREV_SILICON_REF != env.CUR_SILICON_REF) || (env.PREV_CARBON_REF != env.CUR_CARBON_REF)
with:
# Use viper-admin's token to workaround a restriction of GitHub.
# See: https://github.com/peter-evans/create-pull-request/issues/48
token: ${{ secrets.VIPER_ADMIN_TOKEN }}
commit-message: Updates submodules
title: Update Submodules
branch: auto-update-submodules
delete-branch: true
labels: |
automated pr
body: |
${{ env.PR_BODY_LINE1 }}
${{ env.PR_BODY_LINE2 }}
- name: Enable auto-merge of PR
uses: peter-evans/create-or-update-comment@v2
if: (env.PREV_SILICON_REF != env.CUR_SILICON_REF) || (env.PREV_CARBON_REF != env.CUR_CARBON_REF)
with:
token: ${{ secrets.VIPER_ADMIN_TOKEN }}
issue-number: ${{ steps.pr.outputs.pull-request-number }}"
body: bors merge