-
Notifications
You must be signed in to change notification settings - Fork 158
87 lines (76 loc) · 3.19 KB
/
pre_merge_checks.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
# pre_merge_checks.yml/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
# This copyright was auto-generated on Wed, Sep 1, 2021 5:05:35 PM
# This workflow will run pre-merge checks to verify a PR before it is merged:
# - copyright: Checks to see if there are any missing copyrights
name: Pre Merge Checks
on:
pull_request:
branches: [main, develop, release]
jobs:
copyright:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF#refs/heads/})"
id: extract_branch
- name: Checkout PR branch
uses: actions/checkout@v3
with:
ref: ${{ steps.extract_branch.outputs.branch }}
ssh-key: ${{ secrets.PUSH_FROM_WORKFLOW_TO_RETRIGGER }}
- name: Check for (and add) missing copyrights
shell: bash
run: |
make copyright
echo "NUM_MODIFIED=$(git diff --numstat | wc -l)" >> $GITHUB_ENV
- name: Push changes
if: env.NUM_MODIFIED != 0
shell: bash
run: |
git config core.fileMode false
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "updating copyrights from pre merge check in github action"
git push -f origin HEAD:${{ steps.extract_branch.outputs.branch }}
test_github_pages:
needs: copyright
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.8.0
with:
access_token: ${{ github.token }}
- name: Log in to the Container registry
uses: docker/login-action@v1.10.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: Test Jekyll Build and Check Links
run: make tests
ensure_synchronization:
if: github.repository != 'gopro/OpenGoPro' && github.base_ref == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout source branch
uses: actions/checkout@v3
with:
ref: release
ssh-key: ${{ secrets.PUSH_FROM_WORKFLOW_TO_RETRIGGER }}
- name: Verify synchronized if release
shell: bash
run: |
hash=$( git rev-parse HEAD | cut -c1-7)
target_hash=$(git ls-remote git@github.com:gopro/OpenGoPro U main | cut -c1-7)
echo "Target hash is $target_hash"
echo "release hash is $hash"
if [[ $hash == $target_hash ]]; then
exit 0
else
echo "release branch is not synchronized with external main"
exit 1
fi