-
Notifications
You must be signed in to change notification settings - Fork 2k
168 lines (156 loc) · 5.97 KB
/
docker-publish.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
name: docker
on:
# Trigger without any parameters a proactive rebuild
workflow_dispatch: {}
workflow_call:
inputs:
tag_name:
required: true
type: string
env:
REGISTRY: ghcr.io
# Will resolve to foundry-rs/foundry
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: build and push
runs-on: Linux-22.04
permissions:
id-token: write
packages: write
contents: read
timeout-minutes: 120
steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# with:
# cache-on-failure: true
# - name: Install cross
# id: cross_main
# run: |
# cargo install cross
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login into registry ${{ env.REGISTRY }}
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# # Extract metadata (tags, labels) for Docker
# # https://github.com/docker/metadata-action
# - name: Extract Docker metadata
# id: meta
# uses: docker/metadata-action@v4
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
#
# # Creates an additional 'latest' or 'nightly' tag
# # If the job is triggered via cron schedule, tag nightly and nightly-{SHA}
# # If the job is triggered via workflow dispatch and on a master branch, tag branch and latest
# # Otherwise, just tag as the branch name
# - name: Finalize Docker Metadata
# id: docker_tagging
# run: |
# if [[ "${{ github.event_name }}" == 'schedule' ]]; then
# echo "cron trigger, assigning nightly tag"
# echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
# elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
# echo "manual trigger from master/main branch, assigning latest tag"
# echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
# else
# echo "Neither scheduled nor manual release from main branch. Just tagging as branch name"
# echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
# fi
#
# # Log docker metadata to explicitly know what is being pushed
# - name: Inspect Docker Metadata
# run: |
# echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}"
# echo "LABELS -> ${{ steps.meta.outputs.labels }}"
#
# - name: Build and push foundry image
# run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} CARGO_TAG_NAME=${{ inputs.tag_name }} PROFILE=maxperf docker-build-push
- name: Cleanup older images
id: cleanup1
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup2
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup3
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup4
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup5
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup6
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup7
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup8
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'