-
-
Notifications
You must be signed in to change notification settings - Fork 215
149 lines (141 loc) 路 5.31 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
---
#########################
#########################
## 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')
environment:
name: latest
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
########################################################
# Publish updated version of mega-linter-runner on NPM #
########################################################
- uses: actions/setup-node@v3.1.1
with:
node-version: "12.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 }}
###################################
# Run Deploy script for Dockerhub #
###################################
- name: Deploy Release image to Dockerhub
env:
# Set the Env Vars
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_REPO: oxsecurity/megalinter
IMAGE_VERSION: ${{ github.event.release.tag_name }}
DOCKERFILE_PATH: Dockerfile
REGISTRY: Docker
shell: bash
run: .automation/upload-docker.sh
###################################################
# Run Deploy script for GitHub Container Registry #
###################################################
- name: Deploy Release image to GitHub Container Registry
env:
# Set the Env Vars
GCR_USERNAME: ${{ secrets.GCR_USERNAME }}
GCR_TOKEN: ${{ secrets.GCR_PASSWORD }}
IMAGE_REPO: oxsecurity/megalinter
IMAGE_VERSION: ${{ github.event.release.tag_name }}
DOCKERFILE_PATH: Dockerfile
REGISTRY: GCR
shell: bash
run: .automation/upload-docker.sh
# 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
deploy_doc:
runs-on: ubuntu-latest
needs: build
if: github.repository == 'oxsecurity/megalinter'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get release version
id: version
run: |
echo "::set-output name=cversion::$(git describe --tags --match='v*' --abbrev=0 | cut -c2-)"
echo "::set-output name=ctag::$(git describe --tags --match='v*' --abbrev=0)"
echo "::set-output name=pversion::$(git describe --abbrev=0 --match='v*' --tags $(git rev-list --tags --skip=1 --max-count=1) | cut -c2-)"
echo "::set-output name=ptag::$(git describe --abbrev=0 --match='v*' --tags $(git rev-list --tags --skip=1 --max-count=1))"
- 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@v4.2.0
with:
python-version: 3.x
- run: pip install --upgrade markdown==3.3.7 mike mkdocs-material mdx_truly_sane_lists json-schema-for-humans giturlparse webpreview
- 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 megalinter@megalinter.com
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 v6 || true
mike deploy v6 || true
mike deploy --push latest ${{ steps.version.outputs.cversion }}