Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Switch build to GitHub actions (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
der-eismann authored Oct 15, 2021
1 parent d7b5c3e commit 4ee5e37
Showing 1 changed file with 84 additions and 2 deletions.
86 changes: 84 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: Golang CI
name: Golang

on:
push:
branches: [master]
pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]
schedule:
- cron: '15 3 * * 0'

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
name: CI Build

steps:
- name: Setup Go
uses: actions/setup-go@v2
Expand All @@ -25,3 +29,81 @@ jobs:
fetch-depth: 0
- name: Build Project
run: ./buildutil -v

container_build:
runs-on: ubuntu-20.04
name: Container Build

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Generate image tags for releaes
if: ${{ github.event_name == 'release' }}
shell: bash
run: echo "##[set-output name=tags;]quay.io/rebuy/node-drainer:${GITHUB_REF#refs/tags/},074509403805.dkr.ecr.eu-west-1.amazonaws.com/node-drainer:${GITHUB_REF#refs/tags/}"
id: generate_tags_release

- name: Generate image tags for PRs
if: ${{ github.event_name != 'release' }}
shell: bash
run: |
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
echo "##[set-output name=tags;]quay.io/rebuy/node-drainer:${GITHUB_HEAD_REF},074509403805.dkr.ecr.eu-west-1.amazonaws.com/node-drainer:${GITHUB_HEAD_REF}"
else
echo "##[set-output name=tags;]quay.io/rebuy/node-drainer:master,074509403805.dkr.ecr.eu-west-1.amazonaws.com/node-drainer:master,\
quay.io/rebuy/node-drainer:latest,074509403805.dkr.ecr.eu-west-1.amazonaws.com/node-drainer:latest"
fi
id: generate_tags_pr

- name: Set up QEMU
if: ${{ github.event_name == 'release' }}
id: qemu
uses: docker/setup-qemu-action@v1
with:
platforms: arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
install: true

# Only used to prevent rate limits
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to ECR
uses: docker/login-action@v1
with:
registry: 074509403805.dkr.ecr.eu-west-1.amazonaws.com
username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}

- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push
if: ${{ github.event_name == 'release' }}
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.generate_tags_release.outputs.tags }}
platforms: linux/amd64,linux/arm64

- name: Build and push
if: ${{ github.event_name != 'release' }}
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.generate_tags_pr.outputs.tags }}
platforms: linux/amd64

0 comments on commit 4ee5e37

Please sign in to comment.