Skip to content

Commit

Permalink
Merge pull request #10 from ww24/add-multi-platform-docker-images
Browse files Browse the repository at this point in the history
Support multi platforms
  • Loading branch information
ww24 authored Jul 6, 2020
2 parents 85c89f9 + 4a3ae2f commit 32467ab
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 88 deletions.
51 changes: 44 additions & 7 deletions .github/workflows/push.yaml → .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
push:
branches:
- master
pull_request:
branches:
- master

env:
IMAGE_NAME: notifier
DOCKER_REPO: ww24/calendar-notifier
IMAGE_NAME: calendar-notifier
IMAGE_TAG: latest

jobs:
Expand All @@ -15,16 +19,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v1
with:
go-version: "1.13"
go-version: "1.14"
- name: setup env
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
shell: bash
- name: Install go tools
run: cat tools.go | grep _ | awk -F '"' '{print $2}' | xargs -tI {} go install {}
run: cat tools.go | awk -F'"' '/_/ {print $2}' | xargs -tI {} go install {}
- name: go generate
run: go generate ./...
- name: Check uncommitted changes
Expand All @@ -39,9 +49,8 @@ jobs:
- run: go vet ./...
- run: go test -v -race ./...

docker:
needs: test
name: Build and push docker image
docker_build_test:
name: Build docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -67,7 +76,35 @@ jobs:
run: |
trivy -q --severity HIGH,CRITICAL --exit-code 1 \
"docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}"
- name: Push docker image
docker_push:
if: ${{ github.event_name == 'push' }}
needs: [test, docker_build_test]
name: Build and push docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Docker login
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USER}" --password-stdin
- name: Build docker image and push (DockerHub)
run: |
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--output "type=image,push=true" \
-t "${DOCKER_REPO}":${IMAGE_TAG} .
- name: Build docker image and push (GitHub)
run: |
docker build -t "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" .
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u owner --password-stdin docker.pkg.github.com
docker push "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}"
65 changes: 0 additions & 65 deletions .github/workflows/pr.yaml

This file was deleted.

63 changes: 49 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@ on:
- v[0-9]+.[0-9]+.[0-9]+

env:
IMAGE_NAME: notifier
DOCKER_REPO: ww24/calendar-notifier
IMAGE_NAME: calendar-notifier

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v1
with:
go-version: "1.13"
go-version: "1.14"
- name: setup env
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
shell: bash
- name: Install go tools
run: cat tools.go | grep _ | awk -F '"' '{print $2}' | xargs -tI {} go install {}
run: cat tools.go | awk -F'"' '/_/ {print $2}' | xargs -tI {} go install {}
- name: go generate
run: go generate ./...
- name: Check uncommitted changes
Expand All @@ -38,19 +45,13 @@ jobs:
- run: go vet ./...
- run: go test -v -race ./...

docker:
needs: test
name: Build and push docker image
docker_build_test:
name: Build docker image
runs-on: ubuntu-latest
env:
IMAGE_TAG: latest
steps:
- uses: actions/checkout@v1
- name: Set image tag
run: |
tag=$(echo "${GITHUB_REF}" | sed "s/^refs\/tags\/v//")
if [ -z "$tag" ]; then
exit 1
fi
echo "::set-env name=IMAGE_TAG::$tag"
- name: Shellcheck
env:
SHELLCHECK_OPTS: -e SC2187
Expand All @@ -73,7 +74,41 @@ jobs:
run: |
trivy -q --severity HIGH,CRITICAL --exit-code 1 \
"docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}"
- name: Push docker image
docker_push:
needs: [test, docker_build_test]
name: Build and push docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set image tag
run: |
tag=$(echo "${GITHUB_REF}" | sed "s/^refs\/tags\/v//")
if [ -z "$tag" ]; then
exit 1
fi
echo "::set-env name=IMAGE_TAG::$tag"
- name: Docker login
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USER}" --password-stdin
- name: Build docker image and push (DockerHub)
run: |
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--output "type=image,push=true" \
-t "${DOCKER_REPO}":${IMAGE_TAG} .
- name: Push docker image (GitHub)
run: |
docker build -t "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" .
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u owner --password-stdin docker.pkg.github.com
docker push "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}"
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
calendar-notifier
===

![](https://github.com/ww24/calendar-notifier/workflows/Test%20on%20master/badge.svg)
![Test on master][github-actions-img]

Calendar Notifier is Google Calendar event handler and actions.
Calendar Notifier provides event handler and actions triggered by Google Calendar.

[![dockeri.co][dockeri-img]][dockeri-url]

## Features

Expand Down Expand Up @@ -86,3 +88,7 @@ roles/pubsub.publisher

#### References
- https://cloud.google.com/pubsub/docs/access-control

[github-actions-img]: https://github.com/ww24/calendar-notifier/workflows/Test%20on%20master/badge.svg?branch=master
[dockeri-img]: https://dockeri.co/image/ww24/calendar-notifier
[dockeri-url]: https://hub.docker.com/r/ww24/calendar-notifier

0 comments on commit 32467ab

Please sign in to comment.