2019-11-08 09:31:16 -05:00
|
|
|
---
|
|
|
|
#########################
|
|
|
|
#########################
|
|
|
|
## Deploy Docker Image ##
|
|
|
|
#########################
|
|
|
|
#########################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Documentation:
|
|
|
|
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
|
|
|
|
#
|
|
|
|
|
2021-10-01 15:57:26 -04:00
|
|
|
#####################################
|
|
|
|
# Start the job on all push to main #
|
|
|
|
#####################################
|
2020-01-09 14:04:41 -05:00
|
|
|
#############################
|
|
|
|
# Start the job on all push #
|
|
|
|
#############################
|
2019-11-08 09:39:18 -05:00
|
|
|
on:
|
|
|
|
push:
|
2021-10-01 15:57:26 -04:00
|
|
|
branches-ignore: [main]
|
2022-01-06 12:30:14 -05:00
|
|
|
pull_request:
|
2019-11-08 09:31:16 -05:00
|
|
|
|
|
|
|
###############
|
|
|
|
# Set the Job #
|
|
|
|
###############
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
# Name the Job
|
2021-05-25 11:14:43 -04:00
|
|
|
name: Deploy Docker Image - DEV - SLIM
|
2019-11-08 09:31:16 -05:00
|
|
|
# Set the agent to run on
|
|
|
|
runs-on: ubuntu-latest
|
2020-07-01 09:35:15 -04:00
|
|
|
# Prevent duplicate run from happening when a forked push is committed
|
2021-09-14 09:32:24 -04:00
|
|
|
if: ${{ github.event_name == 'push' ||
|
2022-01-06 10:28:26 -05:00
|
|
|
github.event.pull_request.head.repo.full_name != github.repository }}
|
2021-11-15 11:25:36 -05:00
|
|
|
timeout-minutes: 60
|
2019-11-08 09:31:16 -05:00
|
|
|
##################
|
|
|
|
# Load all steps #
|
|
|
|
##################
|
|
|
|
steps:
|
2019-11-08 09:45:57 -05:00
|
|
|
##########################
|
|
|
|
# Checkout the code base #
|
|
|
|
##########################
|
|
|
|
- name: Checkout Code
|
2021-11-10 12:53:31 -05:00
|
|
|
uses: actions/checkout@v2.4.0
|
2021-03-02 09:29:12 -05:00
|
|
|
with:
|
2021-04-22 14:56:18 -04:00
|
|
|
# Full git history is needed to get a proper list
|
|
|
|
# of changed files within `super-linter`
|
2021-03-02 09:29:12 -05:00
|
|
|
fetch-depth: 0
|
2019-11-08 09:45:57 -05:00
|
|
|
|
2020-09-04 05:26:13 -04:00
|
|
|
########################
|
|
|
|
# Get the current date #
|
|
|
|
########################
|
|
|
|
- name: Get current date
|
2021-12-10 11:15:12 -05:00
|
|
|
run: |
|
|
|
|
echo "Appending the build date contents to GITHUB_ENV..."
|
|
|
|
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
|
2020-09-04 05:26:13 -04:00
|
|
|
|
2021-06-24 11:19:42 -04:00
|
|
|
########################
|
|
|
|
# Setup Docker build X #
|
|
|
|
########################
|
|
|
|
- name: Setup BuildX
|
2021-09-07 10:09:45 -04:00
|
|
|
uses: docker/setup-buildx-action@v1.6.0
|
2021-06-24 11:19:42 -04:00
|
|
|
|
|
|
|
################
|
|
|
|
# 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
|
2021-05-25 11:14:43 -04:00
|
|
|
|
2021-06-24 11:19:42 -04:00
|
|
|
###########################################
|
2021-02-03 10:08:08 -05:00
|
|
|
# Build and Push containers to registries #
|
|
|
|
###########################################
|
2021-05-25 11:14:43 -04:00
|
|
|
- name: Build Docker image - SLIM
|
2021-08-24 12:18:02 -04:00
|
|
|
uses: docker/build-push-action@v2.7.0
|
2021-06-24 11:19:42 -04:00
|
|
|
with:
|
|
|
|
context: .
|
2021-12-10 11:15:12 -05:00
|
|
|
file: ./Dockerfile
|
2021-06-24 11:19:42 -04:00
|
|
|
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
|
2021-12-10 11:15:12 -05:00
|
|
|
target: final_slim
|
2021-06-24 11:19:42 -04:00
|
|
|
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
|
2021-02-03 10:08:08 -05:00
|
|
|
run: |
|
2021-06-24 11:19:42 -04:00
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
2021-02-03 10:08:08 -05:00
|
|
|
|
2020-09-04 10:52:04 -04:00
|
|
|
########################################
|
|
|
|
# Validates the metadata docker labels #
|
|
|
|
########################################
|
|
|
|
- name: Run Docker label test cases
|
|
|
|
shell: bash
|
2021-05-25 11:14:43 -04:00
|
|
|
run: .automation/validate-docker-labels.sh "slim"
|
2020-09-04 10:52:04 -04:00
|
|
|
|
2021-03-02 09:29:12 -05:00
|
|
|
########################################
|
|
|
|
# Edit action.yml for test local build #
|
|
|
|
########################################
|
|
|
|
- name: Edit an action.yml file for test local build
|
|
|
|
run: |
|
2021-05-25 11:14:43 -04:00
|
|
|
sed -i "s/super-linter:.*/super-linter:slim-${GITHUB_SHA}'/g" action.yml
|
2021-03-02 09:29:12 -05:00
|
|
|
|
2021-04-22 14:56:18 -04:00
|
|
|
######################
|
|
|
|
# Gather information #
|
|
|
|
######################
|
|
|
|
- name: Gather information about the runtime environment
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
make info
|
|
|
|
|
2021-03-02 09:29:12 -05:00
|
|
|
##########################
|
|
|
|
# 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 }}
|
2021-10-01 21:40:25 -04:00
|
|
|
DEFAULT_BRANCH: main
|
2021-03-02 09:29:12 -05:00
|
|
|
|
2021-05-04 12:33:21 -04:00
|
|
|
###############################################################
|
|
|
|
# Fix file and dir ownership. #
|
|
|
|
# Workaround for https://github.com/actions/runner/issues/434 #
|
|
|
|
###############################################################
|
2021-04-22 14:56:18 -04:00
|
|
|
- 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: |
|
2021-05-25 11:14:43 -04:00
|
|
|
make IMAGE=slim test
|
2021-04-22 14:56:18 -04:00
|
|
|
|
|
|
|
##########################
|
|
|
|
# Codacy Coverage Report #
|
|
|
|
##########################
|
|
|
|
- name: Upload the code coverage report
|
2022-01-06 12:00:42 -05:00
|
|
|
uses: codacy/codacy-coverage-reporter-action@v1.2
|
2021-05-04 12:33:21 -04:00
|
|
|
# Dependabot does not have priv to see the secret, so will
|
|
|
|
# fail opn bump jobs...
|
|
|
|
continue-on-error: true
|
2021-04-22 14:56:18 -04:00
|
|
|
with:
|
|
|
|
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
|
|
|
coverage-reports: test/reports/cobertura/runTests.sh/cobertura.xml
|
|
|
|
|
2020-08-06 14:16:23 -04:00
|
|
|
#####################################
|
|
|
|
# Run Linter against Test code base #
|
|
|
|
#####################################
|
2021-05-25 11:14:43 -04:00
|
|
|
- name: Run Test Cases - SLIM
|
2020-02-04 15:52:18 -05:00
|
|
|
shell: bash
|
2021-04-22 14:56:18 -04:00
|
|
|
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 \
|
2021-07-19 10:28:49 -04:00
|
|
|
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
|
|
|
|
"ghcr.io/github/super-linter:slim-${GITHUB_SHA}"
|
2020-08-06 14:16:23 -04:00
|
|
|
|
|
|
|
#########################################
|
2020-09-21 18:53:30 -04:00
|
|
|
# Clean code base to run against it all #
|
2020-08-06 14:16:23 -04:00
|
|
|
#########################################
|
|
|
|
- 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 #
|
|
|
|
############################################
|
2021-05-25 11:14:43 -04:00
|
|
|
- name: Run against all code base - SLIM
|
2020-08-06 14:16:23 -04:00
|
|
|
shell: bash
|
2021-04-22 14:56:18 -04:00
|
|
|
run: |
|
|
|
|
docker run \
|
|
|
|
-e RUN_LOCAL=true \
|
|
|
|
-e OUTPUT_DETAILS=detailed \
|
|
|
|
-e ACTIONS_RUNNER_DEBUG=true \
|
|
|
|
-e ERROR_ON_MISSING_EXEC_BIT=true \
|
2022-01-06 10:59:15 -05:00
|
|
|
-e YAML_LINTER_RULES=.github/linters/.yaml-linter.yml \
|
2021-07-19 10:28:49 -04:00
|
|
|
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
|
|
|
|
"ghcr.io/github/super-linter:slim-${GITHUB_SHA}"
|