Skip to content

Commit

Permalink
Move image builds to GHA
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>
  • Loading branch information
RealHarshThakur committed May 20, 2021
1 parent f354fe4 commit aa6f05a
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 4 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: release

on:
push:
branches:
- master
tags:
- v*


env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}


jobs:
hnc-manager:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Set Release Tag
run: |
TAG="${GITHUB_REF#refs/*/v}"
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
- name: Set Build Date
id: date
run: |
echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')"
# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '270.0.0'
service_account_key: ${{ secrets.GCR_KEY }}


# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
# Set up docker to authenticate
# via gcloud command-line tool.
gcloud auth configure-docker
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
# add each registry to which the image needs to be pushed here
images: |
gcr.io/k8s-staging-multitenancy/hnc-manager
tag-latest: true
tag-semver: |
{{version}}
- name: Print Tags
run: |
echo "${{ steps.docker_meta.outputs.tags }}"
echo "RELEASE TAG: ${RELEASE_TAG}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: v0.5.1


- name: Build & Push Image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64, linux/arm64, linux/arm/v7
tags: |
${{ steps.docker_meta.outputs.tags }}
build-args: |
DBUILD_DATE=${{ steps.date.outputs.DATE }}
DBUILD_REPO_URL=https://github.com/kubernetes-sigs/hierarchical-namespaces
4 changes: 0 additions & 4 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,4 @@ steps:
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=krew-kubectl-hns.yaml'
# Build Docker image
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/$PROJECT_ID/$_HNC_IMG_NAME:$_HNC_IMG_TAG', 'hierarchical-namespaces']

images: ['gcr.io/$PROJECT_ID/$_HNC_IMG_NAME:$_HNC_IMG_TAG']

0 comments on commit aa6f05a

Please sign in to comment.