Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
eoefans-api/.github/workflows/eoefans-api-docker-ci.yml
View runs Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
88 lines (67 sloc)
2.67 KB
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: EOEFANS API Docker Image CI | |
on: | |
push: | |
tags: ["v*.*.*"] | |
# workflow_dispatch: | |
env: | |
IMAGE_REGISTRY: "containers.vlink.dev" | |
IMAGE_REPO: "eoefans" | |
IMAGE_NAME: "eoefans-api" | |
DOCKERFILE_PATH: "./builder/api/Dockerfile" | |
# IMAGE_TAG: "" #we get tag using the action down below | |
jobs: | |
build: | |
runs-on: [ self-hosted, Linux ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get tag | |
id: tag | |
uses: dawidd6/action-get-tag@v1 | |
- run: | | |
echo "IMAGE_TAG=${{steps.tag.outputs.tag}}" >> $GITHUB_ENV | |
echo "$GITHUB_ENV" | |
- name: write the version to local file (config/version) | |
run: | | |
echo "$IMAGE_TAG" > config/version | |
ls config | |
cat config/version | |
- uses: actions/setup-go@main | |
with: | |
go-version-file: './go.mod' | |
cache-dependency-path: ./go.sum | |
cache: true | |
- run: go version | |
- id: go-cache-paths | |
run: | | |
echo "::set-output name=go-build::$(go env GOCACHE)" | |
echo "::set-output name=go-mod::$(go env GOMODCACHE)" | |
# Cache go build cache, used to speedup go test | |
- name: Go Build Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-build }} | |
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |
# Cache go mod cache, used to speedup builds | |
- name: Go Mod Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-mod }} | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
- name: go dependencies | |
run: go mod download | |
- name: go build | |
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARM=6 go build -ldflags '-w -s' -o api_server vlink.dev/eoefans/cmd/api | |
- name: Log in to VLINK Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the Docker image with tag | |
run: docker build . --file ${{ env.DOCKERFILE_PATH }} ${{ env.DOCKER_BUILD_ARG }} --tag ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
- name: push docker image with tag | |
run: docker push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
- name: re-tag the image to latest version | |
run: docker tag ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:latest | |
- name: push latest docker image | |
run: docker push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:latest |