Try to build with caching to help build times (#1051)

* trying this out

* adding auth

* adding more tags

* check log

* try2

* fix vars

* remove debug

* fix tap

* Revert "fix tap"

This reverts commit 3e1fa4c704.

* checks

* get sha another way

* fix env vars

* making more env

* checking names

* fix repo name

* fix copypasta

* remove spaces

* fixed container name

* fix var and stop uploading dev
This commit is contained in:
Lukas Gravley 2020-12-04 12:49:09 -06:00 committed by GitHub
parent 32b3cde716
commit 37b098dff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 27 deletions

View file

@ -13,6 +13,7 @@ BUILD_DATE="${BUILD_DATE}"
BUILD_REVISION="${GITHUB_SHA}" # GitHub Sha
BUILD_VERSION="${GITHUB_SHA}" # Version of the container
ORG_REPO="github/super-linter" # Org/repo
REGISTRY='ghcr.io' # Docker Registry
((LOG_TRACE = LOG_DEBUG = LOG_VERBOSE = LOG_NOTICE = LOG_WARN = LOG_ERROR = "true")) # Enable all loging
ERROR=0 # Error count
export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR
@ -45,7 +46,7 @@ ValidateLabel() {
########################
# Get the docker label #
########################
LABEL=$(docker inspect --format "{{ index .Config.Labels \"${CONTAINER_KEY}\" }}" "${ORG_REPO}:${GITHUB_SHA}")
LABEL=$(docker inspect --format "{{ index .Config.Labels \"${CONTAINER_KEY}\" }}" "${REGISTRY}/${ORG_REPO}:${GITHUB_SHA}")
###################
# Check the value #

View file

@ -53,8 +53,16 @@ jobs:
# Build image locally for testing #
###################################
- name: Build image
shell: bash
run: docker build --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=${GITHUB_SHA}" --build-arg "BUILD_VERSION=${GITHUB_SHA}" --no-cache -t github/super-linter:${GITHUB_SHA} .
uses: whoan/docker-build-with-cache-action@v5
with:
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }}
registry: ghcr.io
image_name: github/super-linter
image_tag: ${{ github.sha }}
dockerfile: Dockerfile
build_extra_args: "--build-arg=BUILD_DATE=${{ env.BUILD_DATE }} --build-arg=BUILD_REVISION=${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
push_image_and_stages: false
########################################
# Validates the metadata docker labels #
@ -68,7 +76,7 @@ jobs:
#####################################
- name: Run Test Cases
shell: bash
run: docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=tap -e OUTPUT_FOLDER=${GITHUB_SHA} -e OUTPUT_DETAILS=detailed -e ACTIONS_RUNNER_DEBUG=true -e ERROR_ON_MISSING_EXEC_BIT=true -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
run: docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=tap -e OUTPUT_FOLDER=${GITHUB_SHA} -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:${GITHUB_SHA}
#########################################
# Clean code base to run against it all #
@ -82,4 +90,4 @@ jobs:
############################################
- 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 -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
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:${GITHUB_SHA}

View file

@ -39,32 +39,37 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2.3.4
########################
# Get the current date #
########################
- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
#####################
# Run Deploy script #
#####################
- name: Deploy latest image to DockerHub
env:
# Set the Env Vars
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_REPO: github/super-linter
IMAGE_VERSION: latest
DOCKERFILE_PATH: Dockerfile
REGISTRY: Docker
shell: bash
run: .automation/upload-docker.sh
uses: whoan/docker-build-with-cache-action@v5
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
image_name: github/super-linter
image_tag: "latest,v3"
dockerfile: Dockerfile
build_extra_args: "--build-arg=BUILD_DATE=${{ env.BUILD_DATE }} --build-arg=BUILD_REVISION=${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
push_image_and_stages: true
#############################
# Run Deploy script for GPR #
#############################
- name: Deploy Latest image to GitHub Container Registry
env:
# Set the Env Vars
GCR_USERNAME: ${{ secrets.GCR_USERNAME }}
GCR_TOKEN: ${{ secrets.GCR_TOKEN }}
IMAGE_REPO: github/super-linter
IMAGE_VERSION: latest
DOCKERFILE_PATH: Dockerfile
REGISTRY: GCR
shell: bash
run: .automation/upload-docker.sh
uses: whoan/docker-build-with-cache-action@v5
with:
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_TOKEN }}
registry: ghcr.io
image_name: github/super-linter
image_tag: "latest,v3"
dockerfile: Dockerfile
build_extra_args: "--build-arg=BUILD_DATE=${{ env.BUILD_DATE }} --build-arg=BUILD_REVISION=$${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
push_image_and_stages: true

View file

@ -39,6 +39,12 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2.3.4
########################
# Get the current date #
########################
- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
###################################
# Run Deploy script for Dockerhub #
###################################
@ -50,7 +56,7 @@ jobs:
image_name: github/super-linter
image_tag: ${{ github.event.release.tag_name }}
dockerfile: Dockerfile
build_extra_args: "--build-arg=BUILD_DATE=${BUILD_DATE} --build-arg=BUILD_REVISION=${GITHUB_SHA} --build-arg=BUILD_VERSION=${GITHUB_SHA}"
build_extra_args: "--build-arg=BUILD_DATE=${{ env.BUILD_DATE }} --build-arg=BUILD_REVISION=${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
push_image_and_stages: true
###################################################
@ -65,5 +71,5 @@ jobs:
image_name: github/super-linter
image_tag: ${{ github.event.release.tag_name }}
dockerfile: Dockerfile
build_extra_args: "--build-arg=BUILD_DATE=${BUILD_DATE} --build-arg=BUILD_REVISION=${GITHUB_SHA} --build-arg=BUILD_VERSION=${GITHUB_SHA}"
build_extra_args: "--build-arg=BUILD_DATE=${{ github.event.timestamp }}Z --build-arg=BUILD_REVISION=${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
push_image_and_stages: true