-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
139 lines (130 loc) · 4.42 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: "container cache generator"
description: "Generate a cache of container executable paths for a listing of containers."
inputs:
token:
description: GitHub token (required for pull request)
required: false
root:
description: Path of the cache roots (defaults to PWD)
required: false
listing:
description: text file with listing of containers, one per line.
required: true
namespace:
description: namespace to add to each container in the listing (optional)
required: false
org-letter-prefix:
description: set to true to add a letter directory before the organzation name (e.g., docker.io/l/library/ubuntu:latest)
required: true
default: false
repo-letter-prefix:
description: set to true to add a letter directory before the repository name (e.g., docker.io/library/u/ubuntu:latest)
required: true
default: false
registry-letter-prefix:
description: set to true to add a letter directory before the registry name (e.g., d/docker.io/library/ubuntu:latest)
required: true
default: false
dry_run:
description: don't push to update branch (dry run only)
required: false
default: false
branch:
description: branch to open pull request against
required: false
default: main
runs:
using: "composite"
steps:
# We use defaults but provide the repository already cloned
- name: Install shpc and Guts
env:
install_path: ${{ github.action_path }}/lib
branch: main
clone_to: /tmp/container-executable-discovery
full_clone: "false"
run: ${{ github.action_path }}/install/scripts/install.sh
shell: bash
- name: Set root
env:
root: ${{ inputs.root }}
run: |
if [ "${root}" == "" ]; then
root=$(pwd)
fi
echo "root=${root}" >> $GITHUB_ENV
shell: bash
- name: Make Space For Build
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
shell: bash
- name: Update Cache
id: update
env:
registry_prefix: ${{ inputs.registry-letter-prefix }}
repo_prefix: ${{ inputs.repo-letter-prefix }}
org_prefix: ${{ inputs.org-letter-prefix }}
namespace: ${{ inputs.namespace }}
listing: ${{ inputs.listing }}
root: ${{ env.root }}
action_path: ${{ github.action_path }}
run: |
cmd="container-discovery update-cache --root ${root}"
if [ "${repo_prefix}" == "true" ]; then
cmd="${cmd} --repo-letter-prefix"
elif [ "${org_prefix}" == "true" ]; then
cmd="${cmd} --org-letter-prefix"
elif [ "${registry_prefix}" == "true" ]; then
cmd="${cmd} --registry-letter-prefix"
fi
if [ "${namespace}" != "" ]; then
cmd="${cmd} --namespace ${namespace}"
fi
# Add the listing file
cmd="${cmd} ${listing}"
echo "${cmd}"
$cmd
shell: bash
- name: Calculate frequency
env:
root: ${{ env.root }}
run: |
cmd="container-discovery update-counts --root ${root}"
echo "${cmd}"
$cmd
shell: bash
- name: Preview Cache
env:
root: ${{ env.root }}
run: |
sudo apt-get install -y tree || apt-get install -y tree
tree ${root} | head --lines 100
shell: bash
- name: Checkout Update branch
if: (inputs.dry_run != 'true')
env:
root: ${{ env.root }}
GITHUB_TOKEN: ${{ inputs.token }}
BRANCH_AGAINST: ${{ inputs.branch }}
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git config --global pull.rebase true
git add ${root}/* || echo "No files to add"
git add ${root}/*/* || echo "No nested files to add"
git add ${root}/counts.json
git add ${root}/skips.json
git status
if git diff-index --quiet HEAD --; then
printf "No changes\n"
else
export OPEN_PULL_REQUEST=1
printf "Changes\n"
git commit -a -m "Automated deployment with updated cache $(date '+%Y-%m-%d')"
git push origin ${BRANCH_AGAINST}
fi
shell: bash