De-duplicate workflows (#2220)

* De-duplicate deploy-DEV workflows

* Add $

* Fix build target

* Fix standard target

* Consolidate workflows in a single one

* more clean

* add changes

* fix spaces

* fix release

Co-authored-by: Admiral Awkbar <admiralawkbar@github.com>
This commit is contained in:
Marco Ferrari 2022-01-26 16:17:59 +01:00 committed by GitHub
parent feb45bb035
commit c0f47d0eff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 366 additions and 1129 deletions

View file

@ -1,63 +0,0 @@
---
#######################################
#######################################
## Dependabot automerge dependencies ##
#######################################
#######################################
#
# Documentation:
# https://medium.com/@toufik.airane/automerge-github-dependabot-alerts-with-github-actions-7cd6f5763750
#
######################
# name of the action #
######################
name: automerge on pull request
###############
# When to run #
###############
on: [pull_request]
#################
# Start the job #
#################
jobs:
automerge:
name: automerge dependabot
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Wait for CI/CT/CD to succeed
uses: fountainhead/action-wait-for-check@v1.0.0
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Deploy Docker Image - DEV
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Wait for CI/CT/CD to succeed pt2
uses: fountainhead/action-wait-for-check@v1.0.0
id: wait-for-ci
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Stack linter
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: merge
if: steps.wait-for-build.outputs.conclusion == 'success' || steps.wait-for-build.outputs.conclusion == 'skipped' && steps.wait-for-ci.outputs.conclusion == 'success'
uses: actions/github-script@v3
with:
script: |
github.pulls.createReview({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.pull_request.number,
event: 'APPROVE'
})
github.pulls.merge({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.pull_request.number
})

View file

@ -1,207 +0,0 @@
---
#########################
#########################
## Deploy Docker Image ##
#########################
#########################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#####################################
# Start the job on all push to main #
#####################################
#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [main]
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Deploy Docker Image - DEV - SLIM
# Set the agent to run on
runs-on: ubuntu-latest
# Prevent duplicate run from happening when a forked push is committed
if: ${{ github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository }}
timeout-minutes: 60
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2.4.0
with:
# Full git history is needed to get a proper list
# of changed files within `super-linter`
fetch-depth: 0
########################
# Get the current date #
########################
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
########################
# Setup Docker build X #
########################
- name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0
################
# Docker cache #
################
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-slim
restore-keys: |
${{ runner.os }}-single-buildx
###########################################
# Build and Push containers to registries #
###########################################
- name: Build Docker image - SLIM
uses: docker/build-push-action@v2.8.0
with:
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
load: true
push: false
tags: |
ghcr.io/github/super-linter:slim-${{ github.sha }}
ghcr.io/github/super-linter:slim-test
target: final_slim
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#############
# Fix Cache #
#############
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
########################################
# Validates the metadata docker labels #
########################################
- name: Run Docker label test cases
shell: bash
run: .automation/validate-docker-labels.sh "slim"
########################################
# Edit action.yml for test local build #
########################################
- name: Edit an action.yml file for test local build
run: |
sed -i "s/super-linter:.*/super-linter:slim-${GITHUB_SHA}'/g" action.yml
######################
# Gather information #
######################
- name: Gather information about the runtime environment
shell: bash
run: |
make info
##########################
# Test in action context #
##########################
# Test the built image in the actions context.
# Not the container directly, and not using RUN_LOCAL=true
- name: Test the local action
uses: ./
env:
ACTIONS_RUNNER_DEBUG: true
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
###############################################################
# Fix file and dir ownership. #
# Workaround for https://github.com/actions/runner/issues/434 #
###############################################################
- name: Fix file and directory ownership
shell: bash
run: |
sudo chown -R "$(id -u)":"$(id -g)" "$(pwd)"
##################
# Run test cases #
##################
- name: Run the test suite
shell: bash
run: |
make IMAGE=slim test
##########################
# Codacy Coverage Report #
##########################
- name: Upload the code coverage report
uses: codacy/codacy-coverage-reporter-action@v1.3
# Dependabot does not have priv to see the secret, so will
# fail opn bump jobs...
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: test/reports/cobertura/runTests.sh/cobertura.xml
#####################################
# Run Linter against Test code base #
#####################################
- name: Run Test Cases - SLIM
shell: bash
run: |
docker run \
-e RUN_LOCAL=true \
-e TEST_CASE_RUN=true \
-e ANSIBLE_DIRECTORY=.automation/test/ansible \
-e ACTIONS_RUNNER_DEBUG=true \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/github/super-linter:slim-${GITHUB_SHA}"
#########################################
# Clean code base to run against it all #
#########################################
- name: Clean Test code base for additional testing
shell: bash
run: .automation/clean-code-base-for-tests.sh
############################################
# Run Linter against ALL cleaned code base #
############################################
- name: Run against all code base - SLIM
shell: bash
run: |
docker run \
-e RUN_LOCAL=true \
-e OUTPUT_DETAILS=detailed \
-e ACTIONS_RUNNER_DEBUG=true \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-e YAML_LINTER_RULES=.github/linters/.yaml-linter.yml \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/github/super-linter:slim-${GITHUB_SHA}"

View file

@ -1,206 +0,0 @@
---
#########################
#########################
## Deploy Docker Image ##
#########################
#########################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#####################################
# Start the job on all push to main #
#####################################
#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [main]
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Deploy Docker Image - DEV
# Set the agent to run on
runs-on: ubuntu-latest
# Prevent duplicate run from happening when a forked push is committed
if: ${{ github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository }}
timeout-minutes: 60
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2.4.0
with:
# Full git history is needed to get a proper list
# of changed files within `super-linter`
fetch-depth: 0
########################
# Get the current date #
########################
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
########################
# Setup Docker build X #
########################
- name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0
################
# Docker cache #
################
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-standard
restore-keys: |
${{ runner.os }}-single-buildx
###########################################
# Build and Push containers to registries #
###########################################
- name: Build Docker image - Standard
uses: docker/build-push-action@v2.8.0
with:
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
load: true
push: false
tags: |
"ghcr.io/github/super-linter:${{ github.sha }}"
ghcr.io/github/super-linter:test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#############
# Fix Cache #
#############
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
########################################
# Validates the metadata docker labels #
########################################
- name: Run Docker label test cases
shell: bash
run: .automation/validate-docker-labels.sh
########################################
# Edit action.yml for test local build #
########################################
- name: Edit an action.yml file for test local build
run: |
sed -i "s/super-linter:.*/super-linter:${GITHUB_SHA}'/g" action.yml
######################
# Gather information #
######################
- name: Gather information about the runtime environment
shell: bash
run: |
make info
##########################
# Test in action context #
##########################
# Test the built image in the actions context.
# Not the container directly, and not using RUN_LOCAL=true
- name: Test the local action
uses: ./
env:
ACTIONS_RUNNER_DEBUG: true
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
###############################################################
# Fix file and dir ownership. #
# Workaround for https://github.com/actions/runner/issues/434 #
###############################################################
- name: Fix file and directory ownership
shell: bash
run: |
sudo chown -R "$(id -u)":"$(id -g)" "$(pwd)"
##################
# Run test cases #
##################
- name: Run the test suite
shell: bash
run: |
make test
##########################
# Codacy Coverage Report #
##########################
- name: Upload the code coverage report
uses: codacy/codacy-coverage-reporter-action@v1.3
# Dependabot does not have priv to see the secret, so will
# fail opn bump jobs...
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: test/reports/cobertura/runTests.sh/cobertura.xml
#####################################
# Run Linter against Test code base #
#####################################
- name: Run Test Cases - standard
shell: bash
run: |
docker run \
-e RUN_LOCAL=true \
-e TEST_CASE_RUN=true \
-e ANSIBLE_DIRECTORY=.automation/test/ansible \
-e ACTIONS_RUNNER_DEBUG=true \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/github/super-linter:${GITHUB_SHA}"
#########################################
# Clean code base to run against it all #
#########################################
- name: Clean Test code base for additional testing
shell: bash
run: .automation/clean-code-base-for-tests.sh
############################################
# Run Linter against ALL cleaned code base #
############################################
- name: Run against all code base
shell: bash
run: |
docker run \
-e RUN_LOCAL=true \
-e OUTPUT_DETAILS=detailed \
-e ACTIONS_RUNNER_DEBUG=true \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-e YAML_LINTER_RULES=.github/linters/.yaml-linter.yml \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/github/super-linter:${GITHUB_SHA}"

View file

@ -1,185 +0,0 @@
---
#########################
#########################
## Deploy Docker Image ##
#########################
#########################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#####################################
# Start the job on all push to main #
#####################################
on:
push:
branches:
- 'main'
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Deploy Docker Image - PROD - slim
# Set the agent to run on
runs-on: ubuntu-latest
# Only run this on the main repo
if: ${{ github.repository == 'github/super-linter' }}
timeout-minutes: 60
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2.4.0
########################
# Get the current date #
########################
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
########################
# Setup Docker build X #
########################
- name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0
###############################
# Login to DockerHub registry #
###############################
- name: Login to DockerHub
uses: docker/login-action@v1.12.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
######################################
# Login to GitHub Container registry #
######################################
- name: Login to GitHub Container Registry
uses: docker/login-action@v1.12.0
with:
registry: ghcr.io
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }}
#########################
# Update deployment API #
#########################
- name: Start deployment
uses: bobheadxi/deployments@v0.6.2
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: Production-SLIM
################
# Docker cache #
################
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-slim
restore-keys: |
${{ runner.os }}-single-buildx
###########################################
# Build and Push containers to registries #
###########################################
- name: Build and push - SLIM
uses: docker/build-push-action@v2.8.0
with:
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
push: true
tags: |
github/super-linter:slim-latest
ghcr.io/github/super-linter:slim-latest
target: final_slim
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#############
# Fix Cache #
#############
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
#######################################################
# Create a GitHub Issue with the info from this build #
#######################################################
- name: Create GitHub Issue for failure
if: failure()
uses: actions/github-script@v5
id: create-issue
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const create = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Failed to deploy to production",
body: "Automation has failed us!\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
})
console.log('create', create)
return create.data.number
############################
# Assign admins on failure #
############################
- name: Assign Admins on failure
uses: actions/github-script@v5
if: failure()
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: "${{ steps.create-issue.outputs.result }}",
assignees: [
'admiralawkbar',
'lindluni',
'IAmHughes',
'nemchik',
'Hanse00',
'GaboFDC',
'ferrarimarco'
]
})
#########################
# Update Deployment API #
#########################
- name: Update deployment status
uses: bobheadxi/deployments@v0.6.2
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://github.com/github/super-linter

View file

@ -1,184 +0,0 @@
---
#########################
#########################
## Deploy Docker Image ##
#########################
#########################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#####################################
# Start the job on all push to main #
#####################################
on:
push:
branches:
- 'main'
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Deploy Docker Image - PROD - standard
# Set the agent to run on
runs-on: ubuntu-latest
# Only run this on the main repo
if: ${{ github.repository == 'github/super-linter' }}
timeout-minutes: 60
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2.4.0
########################
# Get the current date #
########################
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
########################
# Setup Docker build X #
########################
- name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0
###############################
# Login to DockerHub registry #
###############################
- name: Login to DockerHub
uses: docker/login-action@v1.12.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
######################################
# Login to GitHub Container registry #
######################################
- name: Login to GitHub Container Registry
uses: docker/login-action@v1.12.0
with:
registry: ghcr.io
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }}
#########################
# Update deployment API #
#########################
- name: Start deployment
uses: bobheadxi/deployments@v0.6.2
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: Production
################
# Docker cache #
################
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-standard
restore-keys: |
${{ runner.os }}-single-buildx
###########################################
# Build and Push containers to registries #
###########################################
- name: Build and push - Standard
uses: docker/build-push-action@v2.8.0
with:
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
push: true
tags: |
github/super-linter:latest
ghcr.io/github/super-linter:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#############
# Fix Cache #
#############
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
#######################################################
# Create a GitHub Issue with the info from this build #
#######################################################
- name: Create GitHub Issue for failure
if: failure()
uses: actions/github-script@v5
id: create-issue
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const create = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Failed to deploy to production",
body: "Automation has failed us!\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
})
console.log('create', create)
return create.data.number
############################
# Assign admins on failure #
############################
- name: Assign Admins on failure
uses: actions/github-script@v5
if: failure()
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: "${{ steps.create-issue.outputs.result }}",
assignees: [
'admiralawkbar',
'lindluni',
'IAmHughes',
'nemchik',
'Hanse00',
'GaboFDC',
'ferrarimarco'
]
})
#########################
# Update Deployment API #
#########################
- name: Update deployment status
uses: bobheadxi/deployments@v0.6.2
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://github.com/github/super-linter

307
.github/workflows/deploy-Production.yml vendored Normal file
View file

@ -0,0 +1,307 @@
---
#############################################
#############################################
## Deploy Docker Image test and Production ##
#############################################
#############################################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
###########################################
# Start the job on all push or PR to main #
###########################################
on:
pull_request:
push:
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Deploy Docker Image - DEV
# Set the agent to run on
runs-on: ubuntu-latest
strategy:
matrix:
images:
- container-build-target: final_slim
container-image-id-prefix: slim-
deployment-environment-identifier: Production-SLIM
image-id: slim
- container-build-target: final_standard
container-image-id-prefix: ""
deployment-environment-identifier: Production
image-id: standard
timeout-minutes: 60
###############
# Steps below #
###############
steps:
############################
# Checkout the source code #
############################
- name: Checkout Code
uses: actions/checkout@v2.4.0
with:
# Full git history is needed to get a proper list
# of changed files within `super-linter`
fetch-depth: 0
###########################
# Set current date to ENV #
###########################
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
#######################
# Setup Docker BuildX #
#######################
- name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0
#######################################
# Build local docker images for tests #
#######################################
- name: Build Docker image - ${{ matrix.images.image-id }}
uses: docker/build-push-action@v2.7.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
load: true
push: false
tags: |
ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}${{ github.sha }}
ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}test
target: "${{ matrix.images.container-build-target }}"
################################
# Run local docker labels test #
################################
- name: Run Docker label test cases
shell: bash
run: .automation/validate-docker-labels.sh "${{ matrix.images.image-id }}"
#######################################
# Edit the action.yml for local tests #
#######################################
- name: Edit an action.yml file for test local build
run: |
sed -i "s/super-linter:.*/super-linter:${{ matrix.images.container-image-id-prefix }}${GITHUB_SHA}'/g" action.yml
######################
# Gather information #
######################
- name: Gather information about the runtime environment
shell: bash
run: |
make info
############################################################
# Test the built image in the actions context. #
# Not the container directly, and not using RUN_LOCAL=true #
############################################################
- name: Test the local action
uses: ./
env:
ACTIONS_RUNNER_DEBUG: true
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
###############################################################
# Fix file and dir ownership. #
# Workaround for https://github.com/actions/runner/issues/434 #
###############################################################
- name: Fix file and directory ownership
shell: bash
run: |
sudo chown -R "$(id -u)":"$(id -g)" "$(pwd)"
########################
# Run local make tests #
########################
- name: Run the test suite
shell: bash
run: |
make IMAGE=${{ matrix.images.image-id }} test
##########################
# Codacy Coverage Report #
##########################
- name: Upload the code coverage report
if: ${{ github.repository == 'github/super-linter' }}
uses: codacy/codacy-coverage-reporter-action@v1.1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: test/reports/cobertura/runTests.sh/cobertura.xml
#####################################
# Run Linter against Test code base #
#####################################
- name: Run Test Cases - ${{ matrix.images.image-id }}
shell: bash
run: |
docker run \
-e RUN_LOCAL=true \
-e TEST_CASE_RUN=true \
-e ANSIBLE_DIRECTORY=.automation/test/ansible \
-e ACTIONS_RUNNER_DEBUG=true \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}${GITHUB_SHA}"
#########################################
# Clean code base to run against it all #
#########################################
- name: Clean Test code base for additional testing
shell: bash
run: .automation/clean-code-base-for-tests.sh
############################################
# Run Linter against ALL cleaned code base #
############################################
- name: Run against all code base - ${{ matrix.images.image-id }}
shell: bash
run: |
docker run \
-e RUN_LOCAL=true \
-e OUTPUT_DETAILS=detailed \
-e ACTIONS_RUNNER_DEBUG=true \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}${GITHUB_SHA}"
#############################################################
#############################################################
## The following steps are only run if the PR is merges ##
## into the 'main' branch and push the image to registries ##
#############################################################
#############################################################
######################
# Login to DockerHub #
######################
- name: Login to DockerHub
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' }}
uses: docker/login-action@v1.10.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
####################
# Login to GHCR.io #
####################
- name: Login to GitHub Container Registry
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' }}
uses: docker/login-action@v1.10.0
with:
registry: ghcr.io
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }}
#########################
# Update deployment API #
#########################
- name: Start deployment
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' }}
uses: bobheadxi/deployments@v0.6.1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.images.deployment-environment-identifier }}
######################################
# Build the docker image and push it #
######################################
- name: Build Docker image - ${{ matrix.images.image-id }}
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v2.7.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
load: true
push: true
tags: |
github/super-linter:${{ matrix.images.container-image-id-prefix }}latest
ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}latest
target: "${{ matrix.images.container-build-target }}"
#######################################################
# Create a GitHub Issue with the info from this build #
#######################################################
- name: Create GitHub Issue for failure
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' && failure() }}
uses: actions/github-script@v5
id: create-issue
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const create = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Failed to deploy to production",
body: "Automation has failed us!\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
})
console.log('create', create)
return create.data.number
####################################
# Deploy was failure, alert admins #
####################################
- name: Assign Admins on failure
uses: actions/github-script@v5
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' && failure() }}
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: "${{ steps.create-issue.outputs.result }}",
assignees: [
'admiralawkbar',
'jwiebalk',
'IAmHughes',
'nemchik',
'Hanse00',
'GaboFDC',
'ferrarimarco'
]
})
#########################
# Update Deployment API #
#########################
- name: Update deployment status
if: ${{ github.repository == 'github/super-linter' && github.ref == 'refs/heads/main' }}
uses: bobheadxi/deployments@v0.6.1
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://github.com/github/super-linter

View file

@ -1,206 +0,0 @@
---
#################################
#################################
## Deploy Release Docker Image ##
#################################
#################################
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
##########################################
# Start the job upon a published release #
##########################################
on:
# Start when a release is published
release:
types: ['published']
###############
# Set the Job #
###############
jobs:
deploy:
# Name the Job
name: Deploy Docker Image - Release - standard
# Set the agent to run on
runs-on: ubuntu-latest
#####################################################################
# Only run if Admin start job and it was the Release Issue template #
#####################################################################
if: ${{ github.actor == 'admiralawkbar' || github.actor == 'lindluni' ||
github.actor == 'IAmHughes' || github.actor == 'nemchik' ||
github.actor == 'Hanse00' || github.actor == 'github-actions' ||
github.actor == 'GaboFDC' || github.actor == 'ferrarimarco' }}
timeout-minutes: 60
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2.4.0
#########################
# Update deployment API #
#########################
- name: Start deployment
uses: bobheadxi/deployments@v0.6.2
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: Release
########################
# Get the current date #
########################
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
########################
# Setup Docker build X #
########################
- name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0
###############################
# Login to DockerHub registry #
###############################
- name: Login to DockerHub
uses: docker/login-action@v1.12.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
######################################
# Login to GitHub Container registry #
######################################
- name: Login to GitHub Container Registry
uses: docker/login-action@v1.12.0
with:
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }}
registry: ghcr.io
###########################
# Get the current release #
###########################
- name: Get current Release number
# shellcheck disable=SC2062
run: |
echo "RELEASE_VERSION=$(echo ${{ github.event.release.name }} \
| grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+")" \
>> "${GITHUB_ENV}"
################
# Docker cache #
################
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-standard
restore-keys: |
${{ runner.os }}-single-buildx
###########################################
# Build and Push containers to registries #
###########################################
- name: Build and push - Standard
uses: docker/build-push-action@v2.8.0
with:
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
push: true
tags: |
github/super-linter:latest
github/super-linter:v4
"github/super-linter:${{ env.RELEASE_VERSION }}"
ghcr.io/github/super-linter:latest
ghcr.io/github/super-linter:v4
"ghcr.io/github/super-linter:${{ env.RELEASE_VERSION }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#############
# Fix Cache #
#############
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
#########################
# Update Deployment API #
#########################
- name: Update deployment status
uses: bobheadxi/deployments@v0.6.2
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://github.com/github/super-linter/releases/tag/${{ env.RELEASE_VERSION }}
#######################################################
# Create a GitHub Issue with the info from this build #
#######################################################
- name: Create GitHub Issue for failure
if: failure()
uses: actions/github-script@v5
id: create-issue
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const create = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Failed to deploy release to production",
body: "Automation has failed us! Failed to push release ${{ env.RELEASE_VERSION }}\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
})
console.log('create', create)
return create.data.number
############################
# Assign admins on failure #
############################
- name: Assign Admins on failure
uses: actions/github-script@v5
if: failure()
with:
# https://octokit.github.io/rest.js/v18#issues-create
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: "${{ steps.create-issue.outputs.result }}",
assignees: [
'admiralawkbar',
'lindluni',
'IAmHughes',
'nemchik',
'Hanse00',
'GaboFDC',
'ferrarimarco'
]
})

View file

@ -1,7 +1,7 @@
--- ---
################################# #################################
################################# #################################
## Deploy Release Docker Image ## ## Deploy Docker Image Release ##
################################# #################################
################################# #################################
@ -22,75 +22,70 @@ on:
# Set the Job # # Set the Job #
############### ###############
jobs: jobs:
deploy: build:
# Name the Job # Name the Job
name: Deploy Docker Image - Release - SLIM name: Deploy Docker Image - Release
# Set the agent to run on # Set the agent to run on
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
##################################################################### matrix:
# Only run if Admin start job and it was the Release Issue template # images:
##################################################################### - container-build-target: final_slim
if: ${{ github.actor == 'admiralawkbar' || github.actor == 'lindluni' || container-image-id-prefix: slim-
github.actor == 'IAmHughes' || github.actor == 'nemchik' || deployment-environment-identifier: Release-SLIM
github.actor == 'Hanse00' || github.actor == 'github-actions' || image-id: slim
github.actor == 'GaboFDC' || github.actor == 'ferrarimarco' }} - container-build-target: final_standard
container-image-id-prefix: ""
deployment-environment-identifier: Release
image-id: standard
timeout-minutes: 60 timeout-minutes: 60
################## ###############
# Load all steps # # Steps below #
################## ###############
steps: steps:
########################## ############################
# Checkout the code base # # Checkout the source code #
########################## ############################
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v2.4.0 uses: actions/checkout@v2.4.0
#########################
# Update deployment API #
#########################
- name: Start deployment
uses: bobheadxi/deployments@v0.6.2
id: deployment
with: with:
step: start # Full git history is needed to get a proper list
token: ${{ secrets.GITHUB_TOKEN }} # of changed files within `super-linter`
env: Release-SLIM fetch-depth: 0
######################## ###########################
# Get the current date # # Set current date to ENV #
######################## ###########################
- name: Get current date - name: Get current date
run: | run: |
echo "Appending the build date contents to GITHUB_ENV..." echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}" echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
######################## #######################
# Setup Docker build X # # Setup Docker BuildX #
######################## #######################
- name: Setup BuildX - name: Setup BuildX
uses: docker/setup-buildx-action@v1.6.0 uses: docker/setup-buildx-action@v1.6.0
############################### ######################
# Login to DockerHub registry # # Login to DockerHub #
############################### ######################
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v1.12.0 uses: docker/login-action@v1.10.0
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
###################################### ####################
# Login to GitHub Container registry # # Login to GHCR.io #
###################################### ####################
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v1.12.0 uses: docker/login-action@v1.10.0
with: with:
registry: ghcr.io
username: ${{ secrets.GCR_USERNAME }} username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }} password: ${{ secrets.GCR_TOKEN }}
registry: ghcr.io
########################### ###########################
# Get the current release # # Get the current release #
@ -102,21 +97,21 @@ jobs:
| grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+")" \ | grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+")" \
>> "${GITHUB_ENV}" >> "${GITHUB_ENV}"
################ #########################
# Docker cache # # Update deployment API #
################ #########################
- name: Cache Docker layers - name: Start deployment
uses: actions/cache@v2 uses: bobheadxi/deployments@v0.6.1
id: deployment
with: with:
path: /tmp/.buildx-cache step: start
key: ${{ runner.os }}-single-buildx-slim token: ${{ secrets.GITHUB_TOKEN }}
restore-keys: | env: ${{ matrix.images.deployment-environment-identifier }}
${{ runner.os }}-single-buildx
########################################### ######################################
# Build and Push containers to registries # # Build the docker image and push it #
########################################### ######################################
- name: Build and push - SLIM - name: Build Docker image - ${{ matrix.images.image-id }}
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.8.0
with: with:
context: . context: .
@ -125,28 +120,16 @@ jobs:
BUILD_DATE=${{ env.BUILD_DATE }} BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }} BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }} BUILD_VERSION=${{ github.sha }}
load: true
push: true push: true
tags: | tags: |
github/super-linter:slim-latest github/super-linter:${{ matrix.images.container-image-id-prefix }}latest
github/super-linter:slim-v4 github/super-linter:${{ matrix.images.container-image-id-prefix }}v4
"github/super-linter:slim-${{ env.RELEASE_VERSION }}" github/super-linter:${{ matrix.images.container-image-id-prefix }}${{ env.RELEASE_VERSION }}
ghcr.io/github/super-linter:slim-latest ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}latest
ghcr.io/github/super-linter:slim-v4 ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}v4
"ghcr.io/github/super-linter:slim-${{ env.RELEASE_VERSION }}" ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}${{ env.RELEASE_VERSION }}
target: final_slim target: "${{ matrix.images.container-build-target }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#############
# Fix Cache #
#############
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
######################### #########################
# Update Deployment API # # Update Deployment API #

View file

@ -76,11 +76,9 @@ DOCKERFILE := ''
IMAGE := '' IMAGE := ''
ifeq ($(IMAGE),slim) ifeq ($(IMAGE),slim)
SUPER_LINTER_TEST_CONTINER_URL := "ghcr.io/github/super-linter:slim-test" SUPER_LINTER_TEST_CONTINER_URL := "ghcr.io/github/super-linter:slim-test"
DOCKERFILE := "Dockerfile-slim"
IMAGE := "slim" IMAGE := "slim"
else else
SUPER_LINTER_TEST_CONTINER_URL := "ghcr.io/github/super-linter:test" SUPER_LINTER_TEST_CONTINER_URL := "ghcr.io/github/super-linter:test"
DOCKERFILE := "Dockerfile"
IMAGE := "standard" IMAGE := "standard"
endif endif