Create a Docker image of your Golang app and push it to the Docker registry. Click here for the Dockerfile for the Golang app (https://qiita.com/Yuuki557/items/3d088de91ab86bc71600)
--Workflow file --Capturing the contents
ci.yaml
name: CI
on:
push:
tags:
- "v*.*.*"
jobs:
test:
runs-on: ubuntu-18.04
strategy:
matrix:
go: ["1.15"]
steps:
- name: Check out source code
uses: actions/checkout@v1
- name: Set up Go v${{matrix.go}}
uses: actions/setup-go@v2
with:
go-version: ${{matrix.go}}
- name: Install dependent packages
run: go mod download
- name: Run all test
run: go test -v ./...
docker-build:
needs: ["test"]
runs-on: ubuntu-18.04
env:
DOCKER_IMAGE_NAME: docker-app
steps:
- name: Check out source code
uses: actions/checkout@v1
- name: Build and push docker image
run: |
TAG=$(echo $GITHUB_REF | grep -o "[0-9][\.].*")
DOCKER_IMAGE=${{ secrets.DOCKER_REGISTRY }}/${DOCKER_IMAGE_NAME}:$TAG
echo "Docker image: ${DOCKER_IMAGE}"
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
docker build -t $DOCKER_IMAGE .
docker push $DOCKER_IMAGE
It is triggered by a push in the form of tag v1.0.0. There are many triggers besides push.
The following contents are done in order
The following contents are done in order
Recommended Posts