-
-
Notifications
You must be signed in to change notification settings - Fork 257
68 lines (66 loc) · 2.43 KB
/
_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
64
65
66
67
68
name: Check Changes in Repo
on:
workflow_call:
inputs:
targets:
description: 'The list of services/sub-repositories concerned (as a stringified array)'
type: string
required: true
bypass:
description: 'The check will always return true'
type: boolean
outputs:
changed:
description: 'The list of services that have changed'
value: ${{ jobs.check_changes.outputs.changed }}
target_env:
description: 'The target environment (staging/prod)'
value: ${{ jobs.check_changes.outputs.target_env }}
is_forked:
description: 'Check if repo is a fork'
value: ${{ jobs.check_changes.outputs.is_forked }}
jobs:
check_changes:
runs-on: ubuntu-24.04
name: 'Check for changes in monorepo'
outputs:
changed: ${{ steps.check-changes.outputs.changed }}
target_env: ${{ steps.set_target.outputs.target }}
is_forked: ${{ steps.is_forked.outputs.is_forked }}
env:
TARGETS: ${{ inputs.targets }}
BYPASS: ${{ inputs.bypass }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Set GIT_BRANCH in env'
if: github.event_name != 'pull_request'
id: branch_name
run: |
# Short name for current branch. For PRs, use target branch (base ref)
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: 'Check which folders have changed'
run: |
if [ "${GIT_BRANCH}" == "production" ]; then
echo 'Deploy all'
echo "changed=$TARGETS" >> $GITHUB_OUTPUT
elif [ "${BYPASS}" == true ]; then
echo 'Run all tests'
echo "changed=$TARGETS" >> $GITHUB_OUTPUT
else
changed=$(.github/actions/monorepo/check-changes.sh ${{ github.ref_name }})
echo "changed=$changed" >> $GITHUB_OUTPUT
fi
printf 'changed:%s\n' "${changed[@]}"
shell: bash
id: check-changes
- name: Check if forked PR
id: is_forked
run: |
echo "::set-output name=is_forked::${{github.repository_owner != 'Unlock Protocol' && github.event.pull_request.merged == true}}"
- name: Set target environment
id: set_target
run: |
echo "::set-output name=target::${{ contains(github.base_ref, 'production') && 'prod' || 'staging' }}"