Skip to content

Commit

Permalink
Merge pull request #21 from approvers/action
Browse files Browse the repository at this point in the history
Dockerイメージ作成用DockerfileとGitHub Actions用意
  • Loading branch information
kawaemon authored Jul 7, 2020
2 parents 11765a6 + c764cb4 commit 17f0156
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker

on:
push:
branches:
- master

tags:
- v*

env:
IMAGE_NAME: change-status-go

jobs:
push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Build an image with a tag
run: docker build -t app .

- name: Log into the registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

- name: Push the image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "master" ] && VERSION=latest
docker tag app $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.14.4-alpine3.12 as build
RUN mkdir /src
COPY . /src
WORKDIR /src
RUN go build -a -tags netgo -installsuffix netgo -o change-status-go


FROM scratch
COPY --from=build /src/change-status-go /bot/
WORKDIR /bot/
ENTRYPOINT [ "/bot/change-status-go" ]

0 comments on commit 17f0156

Please sign in to comment.