Skip to content

Commit

Permalink
ci(*) add Docker build and push job (#1625)
Browse files Browse the repository at this point in the history
Add a workflow to build and push Docker images for 2.x based on the new
2.x-only file structure.

Co-authored-by: Shane Utt <shaneutt@linux.com>
  • Loading branch information
Travis Raines and shaneutt committed Aug 2, 2021
1 parent 9842ec0 commit d4a3376
Showing 1 changed file with 72 additions and 2 deletions.
74 changes: 72 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# TODO: right now the release is not fully automated, but the tests below must pass before a release is made manually. See RELEASE.md for more information.
# TODO: need kubernetes latest job (test against v1.20.7 and v1.21.2): https://github.com/Kong/kubernetes-ingress-controller/issues/1616
name: release

on:
push:
branches:
- 'main'
- 'next'
tags:
- 'v2.*'

jobs:
test-current-kubernetes:
Expand Down Expand Up @@ -78,4 +80,72 @@ jobs:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_LOCATION: ${{ secrets.GOOGLE_LOCATION }}

# TODO: need kubernetes latest job (test against v1.20.7 and v1.21.2): https://github.com/Kong/kubernetes-ingress-controller/issues/1616
build-push-images:
needs: [test-current-kubernetes, test-previous-kubernetes]
environment: 'Docker Push'
runs-on: ubuntu-latest
steps:
- name: Parse semver string
id: semver_parser
if: ${{ contains(github.ref, 'tags') }}
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.ref }}
version_extractor_regex: 'refs\/tags\/v(.*)$'
- name: Add standard tags
run: |
echo 'TAGS_STANDARD<<EOF' >> $GITHUB_ENV
echo 'type=ref,event=branch' >> $GITHUB_ENV
echo 'type=semver,pattern={{version}}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Add major.minor tag
if: ${{ steps.semver_parser.outputs.prerelease == '' }}
run: |
echo 'TAGS_SUPPLEMENTAL<<EOF' >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo 'type=semver,pattern={{major}}.{{minor}}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2.1.6
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3.3.0
with:
images: kong/kubernetes-ingress-controller
tags: ${{ env.TAGS_STANDARD }}${{ env.TAGS_SUPPLEMENTAL }}
- name: Build binary
env:
TAG: ${{ steps.meta.outputs.version }}
COMMIT: ${{ github.sha }}
REPO_INFO: https://github.com/${{ github.repository }}.git
id: docker_build_binary
uses: docker/build-push-action@v2
with:
push: false
file: Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
target: builder
- name: Build and push
id: docker_build
env:
TAG: ${{ steps.meta.outputs.version }}
uses: docker/build-push-action@v2
with:
push: true
file: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache

0 comments on commit d4a3376

Please sign in to comment.