-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathaction.yaml
More file actions
70 lines (61 loc) · 1.99 KB
/
Copy pathaction.yaml
File metadata and controls
70 lines (61 loc) · 1.99 KB
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
name: Commit Releases JSON
description: Commits the _releases.json file to the current repository.
inputs:
image-name:
description: 'OCI image name to fetch the releases JSON for'
required: true
releases-branch:
description: 'Branch where the _releases.json file is located'
required: false
default: '_releases'
directory:
description: 'Directory where the _releases branch of the OCI Factory is checked out'
default: oci-factory-releases
required: false
message:
description: 'Commit message for the changes made to _releases.json'
required: true
email:
description: 'Email address to use for the commit author'
required: true
actor:
description: 'GitHub actor to use for the commit author'
default: ${{ github.actor }}
force:
description: 'Force push the changes to the branch'
required: false
default: '0'
runs:
using: "composite"
steps:
- name: commit _releases.json
shell: bash
run: |
if [[ "$RUNNER_DEBUG" == "1" ]]; then
set -x
fi
if [ "${{ inputs.force }}" != "0" ]; then
FORCE='--force'
fi
cd ${{ inputs.directory }}
git config user.email "${{ inputs.email }}"
git config user.name "${{ inputs.actor }}"
release_files=()
for release_file in _releases.json _pro_releases.json; do
path="oci/${{ inputs.image-name }}/${release_file}"
if [[ -f "$path" ]]; then
release_files+=("$path")
fi
done
if [[ ${#release_files[@]} -eq 0 ]]; then
echo "No release files found for ${{ inputs.image-name }}" >&2
exit 1
fi
git add -- "${release_files[@]}"
git commit -m "${{ inputs.message }}"
for i in {1..10}; do
git pull origin ${{ inputs.releases-branch }} --rebase
git push origin ${{ inputs.releases-branch }} $FORCE && break
echo "Retrying push... attempt $i"
sleep 0.5
done