Merge pull request #236 from c445/roehrijn/fix-with-notification #67
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: push | |
jobs: | |
build: | |
# this is to prevent the job to run at forked projects | |
if: github.repository == 'aws/amazon-eks-pod-identity-webhook' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Go Version | |
run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: crazy-max/ghaction-docker-buildx@v3 | |
with: | |
buildx-version: latest | |
qemu-version: latest | |
- name: Build container and push to Dockerhub registry | |
run: | | |
BRANCH=$(echo $GITHUB_REF | cut -d'/' -f3) | |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c -7) | |
REPO=amazon/amazon-eks-pod-identity-webhook | |
if [ "$BRANCH" = "master" ]; then | |
TAG=$SHORT_SHA | |
else | |
TAG=$BRANCH | |
fi | |
if [[ -z "${{ secrets.DOCKERHUB_USER }}" || -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then | |
docker buildx build \ | |
-t $REPO:$TAG \ | |
--build-arg golang_image=public.ecr.aws/eks-distro-build-tooling/golang:${{ env.GO_VERSION }}-gcc \ | |
--platform=linux/amd64,linux/arm64 \ | |
--progress plain \ | |
. | |
exit 0 | |
fi | |
docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }} | |
docker buildx build \ | |
-t $REPO:$TAG \ | |
--build-arg golang_image=public.ecr.aws/eks-distro-build-tooling/golang:${{ env.GO_VERSION }}-gcc \ | |
--platform=linux/amd64,linux/arm64 \ | |
--progress plain \ | |
--push . | |
if [ "$BRANCH" = "master" ]; then | |
docker buildx build \ | |
-t $REPO:latest \ | |
--build-arg golang_image=public.ecr.aws/eks-distro-build-tooling/golang:${{ env.GO_VERSION }}-gcc \ | |
--platform=linux/amd64,linux/arm64 \ | |
--progress plain \ | |
--push . | |
fi | |