forked from External/greenlight
GRN2-XX: updates to github actions for building and publishing alternate images (#2932)
* rework on scripts for git actions * updated ruby version * updated alternate filter * removed ci settings brought forom sl ci * added prefix to image tag and version_code * fixed alternate dockerfile for alpine * updates for amazonlinux alternate image * added missing variables to ci scripts * update of tag in alternate images on release
This commit is contained in:
101
.github/workflows/ci.build.push.yml
vendored
Normal file
101
.github/workflows/ci.build.push.yml
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
env:
|
||||
RUBY_VERSION: 2.7
|
||||
|
||||
name: CI Build Push
|
||||
on:
|
||||
push:
|
||||
branches: "*"
|
||||
|
||||
jobs:
|
||||
main:
|
||||
name: Build Docker Image
|
||||
env:
|
||||
DOCKER_REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }}
|
||||
DOCKER_BUILD_ENABLED: ${{ secrets.DOCKER_BUILD_ENABLED }}
|
||||
DOCKER_BUILD_ALTERNATE_ENABLED: ${{ secrets.DOCKER_BUILD_ALTERNATE_ENABLED }}
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract Docker Repository
|
||||
id: ci_docker_repository
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
shell: bash
|
||||
run: echo "##[set-output name=repository;]$(echo ${DOCKER_REPOSITORY:-$GITHUB_REPOSITORY})"
|
||||
|
||||
- name: Extract Branch Name
|
||||
id: ci_branch_name
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
shell: bash
|
||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
||||
|
||||
- name: Extract Commit Short SHA
|
||||
id: ci_commit_short_sha
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
shell: bash
|
||||
run: echo "##[set-output name=short_sha;]$(echo ${GITHUB_SHA} | cut -c1-7)"
|
||||
|
||||
- name: Build and Push
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
"${{ steps.ci_docker_repository.outputs.repository }}:${{ steps.ci_branch_name.outputs.branch }}"
|
||||
build-args: "VERSION_CODE=${{ steps.ci_branch_name.outputs.branch }}-${{ steps.ci_commit_short_sha.outputs.short_sha }}"
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||
|
||||
# Alternate Image with alpine
|
||||
- name: Alternate Alpine Build and Push
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true') && contains(env.DOCKER_BUILD_ALTERNATE_ENABLED, 'true')
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
file: dockerfiles/v2/alpine
|
||||
push: true
|
||||
tags: |
|
||||
"${{ steps.ci_docker_repository.outputs.repository }}:${{ steps.ci_branch_name.outputs.branch }}-alpine"
|
||||
build-args: "VERSION_CODE=${{ steps.ci_branch_name.outputs.branch }}-${{ steps.ci_commit_short_sha.outputs.short_sha }}"
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||
|
||||
# Alternate Images for bbb-bionic-230 with amazonlinux
|
||||
- name: Alternate Amazon Linux Build and Push
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true') && contains(env.DOCKER_BUILD_ALTERNATE_ENABLED, 'true')
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
file: dockerfiles/v2/amazonlinux
|
||||
push: true
|
||||
tags: |
|
||||
"${{ steps.ci_docker_repository.outputs.repository }}:${{ steps.ci_branch_name.outputs.branch }}-amazonlinux"
|
||||
build-args: "VERSION_CODE=${{ steps.ci_branch_name.outputs.branch }}-${{ steps.ci_commit_short_sha.outputs.short_sha }}"
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||
|
||||
- name: Move cache
|
||||
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
|
||||
run: |
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
Reference in New Issue
Block a user