-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yaml
109 lines (100 loc) · 3.33 KB
/
action.yaml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
name: "checkout-gerrit-change"
description: "Checkout a mirrored Gerrit change"
inputs:
gerrit-refspec:
description: "The Gerrit refspec for the change, eg: refs/changes/YY/NNYY/Z"
required: true
gerrit-project:
description: "The project in Gerrit"
required: true
delay:
description: "Delay in seconds to wait to make sure replication has finished. Default: 10s"
required: false
default: "10s"
fetch-depth:
description: "Number of commits to fetch. 0 indicates all history for all branches and tags. Default 1"
required: false
default: "1"
repository:
description: "Repository name with owner. For example actions/checkout"
required: false
default: ${{ github.repository }}
ref:
description: >
The branch, tag or SHA to checkout. When checking out the repository that
triggered a workflow, this defaults to the reference or SHA for that
event. Otherwise, uses the default branch.
required: false
default: ${{ github.sha }}
token:
description: >
Personal Access token (PAT) used to fetch the repository. The PAT is configured
with the local git config, which enables your scripts to run authenticated git
commands. The post-job step removes the PAT.
We recommend using a service account with the least permissions necessary.
Also, when generating a new PAT, select the least scopes necessary.
default: ${{ github.token }}
gerrit-url:
description: |
The base URL for the gerrit server. This is used if ref can't be found in
the GitHub repository
required: false
default: ""
submodules:
description: >
Whether to checkout submodules: `true` to checkout submodules or
`recursive` to recursively checkout submodules.
Default: false
default: "false"
runs:
using: "composite"
steps:
- id: delay-checkout
run: sleep ${{ inputs.delay }}
shell: bash
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: ${{ inputs.fetch-depth }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
token: ${{ inputs.token }}
submodules: ${{ inputs.submodules }}
- id: gerrit-checkout
shell: bash --noprofile --norc {0}
# yamllint disable rule:line-length
run: |
set -x
report_error_and_exit()
{
default="fatal: couldn't find remote ref ${{ inputs.gerrit-refspec }}"
message=${1:-$default}
echo "$message"
# Log GitHub annotation
echo "::error::$message"
exit 1
}
fetch_from_gerrit()
{
if [ "${{ inputs.gerrit-url }}x" == "x" ]
then
report_error_and_exit "$1"
fi
error=$(git fetch ${{ inputs.gerrit-url }}/${{ inputs.gerrit-project }} ${{ inputs.gerrit-refspec }} 2>&1 > /dev/null)
exit_code=$?
if [ $exit_code -ne 0 ]
then
report_error_and_exit "$error"
fi
}
error=$(git fetch origin ${{ inputs.gerrit-refspec }})
exit_code=$?
if [ $exit_code -ne 0 ]
then
fetch_from_gerrit "$error"
fi
git checkout FETCH_HEAD
if [[ ${{ inputs.submodules }} = [Tt]rue ]]
then
git submodule update
fi