This repository has been archived by the owner on Apr 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
208 lines (199 loc) · 7.23 KB
/
docker-push.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
name: docker-push
on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
push:
branches:
- main
jobs:
update-node:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get @types/node version
uses: actions/[email protected]
id: get_types_node_version
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/scripts/docker_push/update_node/get_types_node_version.js`)
return script()
- uses: actions/[email protected]
with:
node-version: ${{ steps.get_types_node_version.outputs.result }}
- uses: actions/[email protected]
with:
node-version-file: .node-version
cache: npm
- run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/update_node/update_docker_version.sh"
- uses: actions/[email protected]
env:
PACKAGE_ECOSYSTEM: docker
MATCH_PACKAGE_NAME: node
MAX_ALLOWED_VERSION: ${{ steps.get_types_node_version.outputs.result }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/scripts/update_config.js`)
script()
- uses: dev-hato/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: update-node
pr-title-prefix: nodeをアップデートしてあげたよ!
docker-push:
runs-on: ubuntu-latest
needs: update-node
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
REPOSITORY: ${{github.repository}}
permissions:
contents: read
packages: write
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed' && github.repository == github.event.pull_request.head.repo.full_name)
steps:
- uses: actions/[email protected]
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
# jscpd:ignore-start
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: ${{ github.event_name == 'pull_request' }}
# jscpd:ignore-end
- run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/set_env.sh"
- name: Build and push (main)
uses: docker/[email protected]
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml
update-version:
runs-on: ubuntu-latest
needs: docker-push
if: always() && (needs.docker-push.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed'))
permissions:
contents: write
pull-requests: write
env:
REPOSITORY: ${{github.repository}}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get Dependabot Node.js version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
id: get_dependabot_node_version
run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/update_version/get_dependabot_node_version.sh"
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: github.event_name == 'pull_request'
- run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/set_env.sh"
- name: Get Node.js version
id: get_node_version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
env:
DOCKER_CONTENT_TRUST: 1
DEPENDABOT_NODE_VERSION: ${{steps.get_dependabot_node_version.outputs.node_version}}
DEPENDABOT_NPM_VERSION: ${{steps.get_dependabot_node_version.outputs.npm_version}}
run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/update_version/update_versions.sh"
- uses: actions/[email protected]
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: package-lock.json
- if: github.event_name != 'pull_request' || github.event.action != 'closed'
env:
DEPENDABOT_NPM_VERSION: ${{steps.get_dependabot_node_version.outputs.npm_version}}
run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/update_version/npm_install.sh"
- uses: dev-hato/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-version
pr-title-prefix: nodeをアップデートしてあげたよ!
format:
runs-on: ubuntu-latest
needs: update-version
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/[email protected]
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: package-lock.json
- run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/format/fix.sh"
- uses: dev-hato/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-format
pr-title-prefix: formatを直してあげたよ!
update-dockle:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: dev-hato/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
dockle:
runs-on: ubuntu-latest
needs:
- update-dockle
- docker-push
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
steps:
- uses: actions/[email protected]
# jscpd:ignore-start
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: ${{ github.event_name == 'pull_request' }}
# jscpd:ignore-end
- run: bash "${GITHUB_WORKSPACE}/scripts/docker_push/dockle/run_dockle.sh"
docker-push-complete:
runs-on: ubuntu-latest
if: always() && (github.event_name != 'pull_request' || github.event.action != 'closed')
needs:
- format
- dockle
steps:
- if: needs.format.result == 'success' && needs.dockle.result == 'success'
run: exit 0
- if: ${{ !(needs.format.result == 'success' && needs.dockle.result == 'success') }}
run: exit 1
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true