-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (155 loc) · 5.47 KB
/
tag.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Tag Images
on:
workflow_dispatch:
inputs:
originalTag:
description: 'Original tag; please ensure its appearance on Wiki homepage'
default: '2099.3-<branch_name>'
required: true
dryRun:
type: boolean
description: 'dry-run: retrieve original image names ONLY'
required: true
jobs:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ami-079a0c9425d45e778
ec2-instance-type: t3.2xlarge
subnet-id: subnet-0c4a81ef57cf2ebe3
security-group-id: sg-01cb8c0cb0de3ba00
gpu_test:
uses: ./.github/workflows/test_gpu.yml
with:
originalTag: ${{ github.event.inputs.originalTag }}
dryRun: ${{ github.event.inputs.dryRun == 'true' }}
secrets:
inherit
tagging:
needs:
- gpu_test
- start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- uses: actions/checkout@v3
- name: Docker Cleanup
run: |
docker image prune -a -f
docker container prune -f
- name: Install pip dependencies
run: |
sudo dnf -y install python-pip
sudo dnf remove python3-requests -y
python3 -m pip install -r scripts/requirements.txt
- name: Install pydoit fixed
run: |
git clone https://github.com/davidzyx/doit
pip install ./doit
rm -rf ./doit
mkdir -p logs manifests
touch logs/run.log logs/.empty
- name: Set Python-specific environment variables
run: |
echo "PYTHONPATH=$(pwd)" >> $GITHUB_ENV
echo "PYTHONUNBUFFERED=TRUE" >> $GITHUB_ENV
- name: Clone Wiki
uses: actions/checkout@v3
with:
repository: ${{github.repository}}.wiki
path: wiki
- name: Setup artifacts
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
run: |
doit prep
mkdir -p logs
- name: Dry-run Tagging
if: ${{ github.event.inputs.dryRun == 'true' }}
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
run: >
doit tag
--original_tag ${{ github.event.inputs.originalTag }}
--dry_run
- name: Tag Images
if: ${{ github.event.inputs.dryRun == 'false' }}
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
run: >
doit tag
--original_tag ${{ github.event.inputs.originalTag }}
- name: Update Wiki, Home.md
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
run: >
doit home
- name: Push Wiki to GitHub
if: >
(github.event.inputs.dryRun == 'false') &&
!contains(github.base_ref , 'test') &&
!contains(github.base_ref , 'dev') &&
!contains(github.event.head_commit.message , 'skip push') &&
(
github.ref == 'refs/heads/main'
)
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[ci skip] Automated publish for ${{github.sha}}'
repository: wiki/
- name: Archive artifacts and logs
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: tag-artifacts
path: |
artifacts
manifests
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- tagging # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}