Skip to content

v7.9.0

v7.9.0 #154

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"]
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:
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: "18.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 Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
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 Image
uses: docker/build-push-action@v5
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: |
docker.io/oxsecurity/megalinter:v7
docker.io/oxsecurity/megalinter:${{ github.event.release.tag_name }}
docker.io/oxsecurity/megalinter:latest
ghcr.io/oxsecurity/megalinter:v7
ghcr.io/oxsecurity/megalinter:${{ github.event.release.tag_name }}
ghcr.io/oxsecurity/megalinter:latest
- name: Build Worker Image
uses: docker/build-push-action@v5
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: |
docker.io/oxsecurity/megalinter-worker:v7
docker.io/oxsecurity/megalinter-worker:${{ github.event.release.tag_name }}
docker.io/oxsecurity/megalinter-worker:latest
ghcr.io/oxsecurity/megalinter-worker:v7
ghcr.io/oxsecurity/megalinter-worker:${{ github.event.release.tag_name }}
ghcr.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 v7 || true
mike deploy v7 || true
mike deploy --push latest ${{ steps.version.outputs.cversion }}