Skip to content

Commit

Permalink
feat: added docker build wf
Browse files Browse the repository at this point in the history
  • Loading branch information
rlardy-ulule committed Dec 4, 2023
1 parent 3d85f6f commit e5f67c9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
version: latest
args: -v -c .golangci.yml --timeout 10m
# skip-cache: true
# skip-pkg-cache: true
skip-pkg-cache: true
# skip-build-cache: true
56 changes: 56 additions & 0 deletions .github/workflows/mover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: mover

on:
push:
branches-ignore:
- 'main'
pull_request:
types: [closed]
branches:
- 'main'

jobs:

build:
timeout-minutes: 30
runs-on: [self-hosted, linux, x64]

steps:
- name: Checking out repository
uses: actions/checkout@v3

- name: Login to GCR
uses: docker/login-action@v2
with:
registry: ${{ vars.REGISTRY }}
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ulule
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Removing slashes from branch name when not tag or dev branch
id: git_tag
run: |
if [[ "${{ github.event.pull_request.merged }}" == "true" ]] && [[ "${{ github.ref_name }}" == 'main' ]] && [[ "${{ github.event.pull_request.title }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "GIT_TAG=${{ github.event.pull_request.title }}" >> "$GITHUB_OUTPUT"
else
echo "GIT_TAG=${GIT_REF//\//-}" >> "$GITHUB_OUTPUT"
fi
env:
GIT_REF: ${{ github.ref_name }}

- name: Build app and push
uses: docker/build-push-action@v4
with:
file: Dockerfile
push: true
tags: ${{ vars.REGISTRY }}/mover:${{ github.sha }},${{ vars.REGISTRY }}/mover:${{ steps.git_tag.outputs.GIT_TAG }}
cache-from: type=registry,ref=${{ vars.REGISTRY }}/mover:cache
cache-to: type=registry,ref=${{ vars.REGISTRY }}/mover:cache,mode=min,compression=zstd
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG CGO_ENABLED=0

WORKDIR /go/src/github.com/ulule/mover

COPY --link . .
COPY . .

RUN --mount=type=cache,target=/root/.cache/go-build \
go build -o mover ./cmd/mover/
Expand Down

0 comments on commit e5f67c9

Please sign in to comment.