forked from tiiuae/ghaf
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (60 loc) · 2.45 KB
/
build-yml-check.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
# SPDX-FileCopyrightText: 2022-2023 TII (SSRC) and the Ghaf contributors
#
# SPDX-License-Identifier: Apache-2.0
on:
workflow_call:
outputs:
result:
value: ${{ jobs.check.outputs.result }}
jobs:
check:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.set-output.outputs.result }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if build.yml is modified
id: build-yml-changed
uses: tj-actions/changed-files@v40
with:
files: .github/workflows/build.yml
- name: Set output
id: set-output
run: |
# Not changed
if [ "${{ steps.build-yml-changed.outputs.any_changed }}" != "true" ];
then
echo "result=not-changed"
echo "result=not-changed" >> "$GITHUB_OUTPUT"
exit 0
fi
# Changed from external PR
if [ "${{ github.event_name }}" = "pull_request_target" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ];
then
echo "::error::"\
"Editing workflow file '.github/workflows/build.yml' with PR from a"\
"forked repository is not allowed. The change you are trying to do"\
"requires internal PR from someone with write access to this repo."
echo "result=changed-from-fork"
echo "result=changed-from-fork" >> "$GITHUB_OUTPUT"
exit 1
fi
# Changed from internal PR
echo "::error::"\
"This change edits workflow file '.github/workflows/build.yml' from"\
"an internal PR. Raising this error (but not failing the job) to notify"\
"that the build workflow change will only take impact after merge."\
"Therefore, you need to manually test the change (perhaps in a"\
"forked repo) before merge to make sure the change does not break"\
"anything."\
"For now, there's no point of running the remaining build steps since"\
"the results would not reflect the modification you have done to the"\
"workflow, and might cause confusion or misinterpretation."\
"Skipping the build step."
echo "result=changed-from-internal"
echo "result=changed-from-internal" >> "$GITHUB_OUTPUT"
exit 0