v9.4.0 #180
Workflow file for this run
This file contains hidden or 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: | |
| 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@v8 | |
| 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@v6 | |
| - 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" | |
| 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@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 }} | |
| # MAJOR-RELEASE-IMPACTED | |
| tags: | | |
| ghcr.io/oxsecurity/megalinter:v9 | |
| 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 | |
| # 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@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@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@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: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@v6 | |
| - name: Prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - 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 Flavor Builder Image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| 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 | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@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@v8 | |
| with: | |
| path: ${{ runner.temp }}/digests | |
| pattern: custom-flavor-builder-digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| 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: | | |
| 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 }} | |
| deploy_doc: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.repository == 'oxsecurity/megalinter' | |
| permissions: | |
| contents: write | |
| environment: | |
| name: release | |
| steps: | |
| - uses: actions/checkout@v6 | |
| 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@v6 | |
| with: | |
| python-version: 3.12.12 | |
| - 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 }} | |
| - 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 | |
| # MAJOR-RELEASE-IMPACTED | |
| run: | | |
| mike delete latest | |
| mike delete v9 || true | |
| mike deploy v9 || true | |
| mike deploy --push latest ${{ steps.version.outputs.cversion }} |