-
-
Notifications
You must be signed in to change notification settings - Fork 242
212 lines (201 loc) · 8 KB
/
deploy-RELEASE.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
209
210
211
212
---
#########################
#########################
## Deploy Docker Image ##
#########################
#########################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#######################################
# Start the job on all push to main #
#######################################
name: "Build & Deploy - RELEASE"
on:
release:
# Want to run the automation when a release is created
types: ["created"]
paths:
- "Dockerfile"
- "megalinter/**"
- "mega-linter-runner/**"
- "flavors/**"
- "**/linter-versions.json"
- "**/.sh"
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Deploy Docker Image - RELEASE
# Set the agent to run on
runs-on: ubuntu-latest
# Only run on main repo
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
permissions:
actions: write
packages: write
environment:
name: release
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v4
########################################################
# Publish updated version of mega-linter-runner on NPM #
########################################################
- uses: actions/[email protected]
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: cd mega-linter-runner && npm install
- run: cd mega-linter-runner && npm publish || echo "mega-linter-runner not published"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Free disk space
- name: Free Disk space
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
- name: Build Image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile-release
platforms: linux/amd64
build-args: |
MEGALINTER_BASE_IMAGE=docker.io/oxsecurity/megalinter:beta
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.event.release.tag_name }}
load: false
push: true
secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/oxsecurity/megalinter:v8
ghcr.io/oxsecurity/megalinter:${{ github.event.release.tag_name }}
ghcr.io/oxsecurity/megalinter:latest
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:v8", "target-image": "docker.io/oxsecurity/megalinter:v8" }'
ref: main
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:v8", "target-image": "docker.io/oxsecurity/megalinter:${{ github.event.release.tag_name }}" }'
ref: main
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:v8", "target-image": "docker.io/oxsecurity/megalinter:latest" }'
ref: main
# - name: Build Worker Image
# uses: docker/build-push-action@v6
# with:
# context: .
# file: Dockerfile-release
# platforms: linux/amd64
# build-args: |
# MEGALINTER_BASE_IMAGE=docker.io/oxsecurity/megalinter-worker:beta
# BUILD_DATE=${{ env.BUILD_DATE }}
# BUILD_REVISION=${{ github.sha }}
# BUILD_VERSION=${{ github.event.release.tag_name }}
# load: false
# push: true
# secrets: |
# GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
# tags: |
# ghcr.io/oxsecurity/megalinter-worker:v8
# ghcr.io/oxsecurity/megalinter-worker:${{ github.event.release.tag_name }}
# ghcr.io/oxsecurity/megalinter-worker:latest
# - name: Invoke Mirror docker image workflow (Worker image)
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: mirror-docker-image.yml
# inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker:v8", "target-image": "docker.io/oxsecurity/megalinter-worker:v8" }'
# - name: Invoke Mirror docker image workflow (Worker image)
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: mirror-docker-image.yml
# inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker:v8", "target-image": "docker.io/oxsecurity/megalinter-worker:${{ github.event.release.tag_name }}" }'
# - name: Invoke Mirror docker image workflow (Worker image)
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: mirror-docker-image.yml
# inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker:v8", "target-image": "docker.io/oxsecurity/megalinter-worker:latest" }'
deploy_doc:
runs-on: ubuntu-latest
needs: build
if: github.repository == 'oxsecurity/megalinter'
permissions:
contents: write
environment:
name: release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get release version
id: version
run: |
{
echo "cversion=$(git describe --tags --match='v*' --abbrev=0 | cut -c2-)"
echo "ctag=$(git describe --tags --match='v*' --abbrev=0)"
echo "pversion=$(git describe --abbrev=0 --match='v*' --tags "$(git rev-list --tags --skip=1 --max-count=1)" | cut -c2-)"
echo "ptag=$(git describe --abbrev=0 --match='v*' --tags "$(git rev-list --tags --skip=1 --max-count=1)")"
} >>"$GITHUB_OUTPUT"
- name: Print tags
run: |
echo "prev tag ${{ steps.version.outputs.ptag }}"
echo "curr tag ${{ steps.version.outputs.ctag }}"
echo "prev ver ${{ steps.version.outputs.pversion }}"
echo "curr ver ${{ steps.version.outputs.cversion }}"
- uses: actions/setup-python@v5
with:
python-version: 3.12.0
- run: pip install --upgrade -r .config/python/dev/requirements.txt
- run: cd .automation && bash build_schemas_doc.sh && cd ..
# - run: mkdocs gh-deploy --force
- run: |
git config --global user.name megalinter-bot
git config --global user.email [email protected]
git stash
- name: Checkout previous tag
run: |
git checkout ${{ steps.version.outputs.ptag }}
- name: Mike deploy previous version
run: |
mike delete ${{ steps.version.outputs.pversion }} || echo 'version does not exists yet'
mike deploy ${{ steps.version.outputs.pversion }}
- name: Checkout current tag
run: |
git checkout ${{ steps.version.outputs.ctag }}
- name: Mike deploy current version
run: |
mike delete latest
mike delete v8 || true
mike deploy v8 || true
mike deploy --push latest ${{ steps.version.outputs.cversion }}