Skip to content

v9.6.0

v9.6.0 #183

Workflow file for this run

---
#########################
#########################
## 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"]
###############
# Set the Job #
###############
permissions: {}
jobs:
publish_runner:
name: Publish mega-linter-runner (release)
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
steps:
- name: Trigger deploy-mega-linter-runner workflow
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: ".github/workflows/deploy-mega-linter-runner.yml",
ref: "main",
inputs: {
"dist-tag": "latest",
prerelease: "false",
preid: "beta"
},
});
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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
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"
sudo rm -rf /opt/hostedtoolcache/CodeQL # large cache
sudo rm -rf /opt/hostedtoolcache/go # Go toolcache
- 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@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
with:
context: .
file: Dockerfile-release
platforms: linux/amd64
build-args: |
MEGALINTER_BASE_IMAGE=ghcr.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 }}
# MAJOR-RELEASE-IMPACTED
tags: |
ghcr.io/oxsecurity/megalinter:v9
ghcr.io/oxsecurity/megalinter:${{ github.event.release.tag_name }}
ghcr.io/oxsecurity/megalinter:latest
# Release is one-shot per tag — read BETA's warm cache only. No
# cache-to since nobody reads release-* entries.
cache-from: type=gha,scope=beta-main,ignore-error=true
# Docker Hub mirroring is disabled — MegaLinter is published to ghcr.io only.
# - name: Invoke Mirror docker image workflow (Main image)
# uses: benc-uk/workflow-dispatch@7a027648b88c2413826b6ddd6c76114894dc5ec4 # v1
# with:
# workflow: mirror-docker-image.yml
# # MAJOR-RELEASE-IMPACTED
# inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:v9", "target-image": "docker.io/oxsecurity/megalinter:v9" }'
# ref: main
# - name: Invoke Mirror docker image workflow (Main image)
# uses: benc-uk/workflow-dispatch@7a027648b88c2413826b6ddd6c76114894dc5ec4 # v1
# with:
# workflow: mirror-docker-image.yml
# # MAJOR-RELEASE-IMPACTED
# inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:v9", "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@7a027648b88c2413826b6ddd6c76114894dc5ec4 # v1
# with:
# workflow: mirror-docker-image.yml
# # MAJOR-RELEASE-IMPACTED
# inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:v9", "target-image": "docker.io/oxsecurity/megalinter:latest" }'
# ref: main
# - name: Build Worker Image
# uses: docker/build-push-action@v7
# with:
# context: .
# file: Dockerfile-release
# platforms: linux/amd64
# build-args: |
# MEGALINTER_BASE_IMAGE=ghcr.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:v9
# 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:v9", "target-image": "docker.io/oxsecurity/megalinter-worker:v9" }'
# - 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:v9", "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:v9", "target-image": "docker.io/oxsecurity/megalinter-worker:latest" }'
build-custom-flavor-builder:
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
# Name the Job
name: Deploy Docker Image (Custom Flavor Builder) - RELEASE
# Set the agent to run on
runs-on: ${{ matrix.runner }}
# 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> "${GITHUB_ENV}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
- name: Build Flavor Builder Image
id: build
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
with:
context: .
file: Dockerfile-custom-flavor
platforms: ${{ matrix.platform }}
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.event.release.tag_name }}
secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
# MAJOR-RELEASE-IMPACTED
outputs: type=image,"name=ghcr.io/${{ github.repository }}-custom-flavor-builder",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
env:
RUNNER_TEMP: ${{ runner.temp }}
BUILD_DIGEST: ${{ steps.build.outputs.digest }}
run: |
mkdir -p "${RUNNER_TEMP}/digests"
digest="${BUILD_DIGEST}"
touch "${RUNNER_TEMP}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: custom-flavor-builder-digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge-custom-flavor-builder:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- build-custom-flavor-builder
steps:
- name: Download digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: ${{ runner.temp }}/digests
pattern: custom-flavor-builder-digests-*
merge-multiple: true
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
- name: Docker meta
id: meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
with:
images: ghcr.io/${{ github.repository }}-custom-flavor-builder
tags: |
type=raw,value=v9
type=raw,value=${{ github.event.release.tag_name }}
type=raw,value=latest
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
# shellcheck disable=SC2046
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ github.repository }}-custom-flavor-builder@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository }}-custom-flavor-builder:"${STEPS_META_OUTPUTS_VERSION}"
env:
STEPS_META_OUTPUTS_VERSION: ${{ steps.meta.outputs.version }}
deploy_doc:
runs-on: ubuntu-latest
needs: build
if: github.repository == 'oxsecurity/megalinter'
permissions:
contents: write
environment:
name: release
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
# Keep the GITHUB_TOKEN in the git config so `mike deploy --push` can push to gh-pages.
persist-credentials: true
- name: Get release version
id: version
# Match only full semver tags (vN.N.N) so the moving major-version tag (e.g. `v9`) is ignored.
run: |
{
echo "cversion=$(git describe --tags --match='v[0-9]*.[0-9]*.[0-9]*' --abbrev=0 | cut -c2-)"
echo "ctag=$(git describe --tags --match='v[0-9]*.[0-9]*.[0-9]*' --abbrev=0)"
echo "pversion=$(git describe --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' --tags "$(git rev-list --tags='v[0-9]*.[0-9]*.[0-9]*' --skip=1 --max-count=1)" | cut -c2-)"
echo "ptag=$(git describe --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' --tags "$(git rev-list --tags='v[0-9]*.[0-9]*.[0-9]*' --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}"
env:
STEPS_VERSION_OUTPUTS_PTAG: ${{ steps.version.outputs.ptag }}
STEPS_VERSION_OUTPUTS_CTAG: ${{ steps.version.outputs.ctag }}
STEPS_VERSION_OUTPUTS_PVERSION: ${{ steps.version.outputs.pversion }}
STEPS_VERSION_OUTPUTS_CVERSION: ${{ steps.version.outputs.cversion }}
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: 3.14.6
- 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 129584137+megalinter-bot@users.noreply.github.com
git stash
- name: Checkout previous tag
run: |
git checkout "${STEPS_VERSION_OUTPUTS_PTAG}"
env:
STEPS_VERSION_OUTPUTS_PTAG: ${{ 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}"
env:
STEPS_VERSION_OUTPUTS_PVERSION: ${{ steps.version.outputs.pversion }}
- name: Checkout current tag
run: |
git checkout "${STEPS_VERSION_OUTPUTS_CTAG}"
env:
STEPS_VERSION_OUTPUTS_CTAG: ${{ steps.version.outputs.ctag }}
- name: Mike deploy current version
# MAJOR-RELEASE-IMPACTED
# mike version names are the major number without the "v" prefix (e.g. "9", not "v9").
# The final command deploys the "latest" version with the full release as an alias
# (matches the historical layout in versions.json: {"version": "latest", "aliases": ["x.y.z"]}).
run: |
mike delete latest || true
mike delete 9 || true
mike deploy 9
mike deploy --push latest "${STEPS_VERSION_OUTPUTS_CVERSION}"
env:
STEPS_VERSION_OUTPUTS_CVERSION: ${{ steps.version.outputs.cversion }}