v8.2.0 #163
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
######################### | |
######################### | |
## 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" }' | |
- 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 }}" }' | |
- 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" }' | |
# - 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 }} |