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_REVISION="${GITHUB_SHA}" # GitHub Sha
BUILD_VERSION="${GITHUB_SHA}" # Version of the container BUILD_VERSION="${GITHUB_SHA}" # Version of the container
ORG_REPO="github/super-linter" # Org/repo 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 ((LOG_TRACE = LOG_DEBUG = LOG_VERBOSE = LOG_NOTICE = LOG_WARN = LOG_ERROR = "true")) # Enable all loging
ERROR=0 # Error count ERROR=0 # Error count
export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR
@ -45,7 +46,7 @@ ValidateLabel() {
######################## ########################
# Get the docker label # # 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 # # Check the value #

View file

@ -53,8 +53,16 @@ jobs:
# Build image locally for testing # # Build image locally for testing #
################################### ###################################
- name: Build image - name: Build image
shell: bash uses: whoan/docker-build-with-cache-action@v5
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} . 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 # # Validates the metadata docker labels #
@ -68,7 +76,7 @@ jobs:
##################################### #####################################
- name: Run Test Cases - name: Run Test Cases
shell: bash 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 # # Clean code base to run against it all #
@ -82,4 +90,4 @@ jobs:
############################################ ############################################
- name: Run against all code base - name: Run against all code base
shell: bash 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 - name: Checkout Code
uses: actions/checkout@v2.3.4 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 # # Run Deploy script #
##################### #####################
- name: Deploy latest image to DockerHub - name: Deploy latest image to DockerHub
env: uses: whoan/docker-build-with-cache-action@v5
# Set the Env Vars with:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_REPO: github/super-linter image_name: github/super-linter
IMAGE_VERSION: latest image_tag: "latest,v3"
DOCKERFILE_PATH: Dockerfile dockerfile: Dockerfile
REGISTRY: Docker build_extra_args: "--build-arg=BUILD_DATE=${{ env.BUILD_DATE }} --build-arg=BUILD_REVISION=${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
shell: bash push_image_and_stages: true
run: .automation/upload-docker.sh
############################# #############################
# Run Deploy script for GPR # # Run Deploy script for GPR #
############################# #############################
- name: Deploy Latest image to GitHub Container Registry - name: Deploy Latest image to GitHub Container Registry
env: uses: whoan/docker-build-with-cache-action@v5
# Set the Env Vars with:
GCR_USERNAME: ${{ secrets.GCR_USERNAME }} username: ${{ secrets.GCR_USERNAME }}
GCR_TOKEN: ${{ secrets.GCR_TOKEN }} password: ${{ secrets.GCR_TOKEN }}
IMAGE_REPO: github/super-linter registry: ghcr.io
IMAGE_VERSION: latest image_name: github/super-linter
DOCKERFILE_PATH: Dockerfile image_tag: "latest,v3"
REGISTRY: GCR dockerfile: Dockerfile
shell: bash build_extra_args: "--build-arg=BUILD_DATE=${{ env.BUILD_DATE }} --build-arg=BUILD_REVISION=$${{ github.sha }} --build-arg=BUILD_VERSION=${{ github.sha }}"
run: .automation/upload-docker.sh push_image_and_stages: true

View file

@ -39,6 +39,12 @@ jobs:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v2.3.4 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 # # Run Deploy script for Dockerhub #
################################### ###################################
@ -50,7 +56,7 @@ jobs:
image_name: github/super-linter image_name: github/super-linter
image_tag: ${{ github.event.release.tag_name }} image_tag: ${{ github.event.release.tag_name }}
dockerfile: Dockerfile 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 push_image_and_stages: true
################################################### ###################################################
@ -65,5 +71,5 @@ jobs:
image_name: github/super-linter image_name: github/super-linter
image_tag: ${{ github.event.release.tag_name }} image_tag: ${{ github.event.release.tag_name }}
dockerfile: Dockerfile 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 push_image_and_stages: true