Skip to content

Commit

Permalink
actions and Dockerfile added
Browse files Browse the repository at this point in the history
  • Loading branch information
Slimo300 committed Mar 24, 2024
1 parent b5696a3 commit 03e19df
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v3

- name: Get current tag of Docker Image
id: obtain-new-image
run: |
current_version=$(skopeo inspect docker://slimo300/yamlak | jq -r '.RepoTags | .[-1]')
current_version=${current_version##*:}
new_image="slimo300/yamlak:$(echo $current_version | awk -F '.' '{print $1"."$2"."($3 + 1)}')"
echo "::set-output name=new-image::$new_image"
- name: Build Docker Image
run: docker build -t ${{ steps.obtain-new-image.outputs.new-image }} .

- name: Log In to DockerHub
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish an Image
run: docker push ${{ steps.obtain-new-image.outputs.new-image }}

33 changes: 33 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test

on: [ pull_request ]

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false
- name: Lint Go Code
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: .
args: --timeout=10m
Test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false
- name: Test Go Code
run: go test ./...
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# syntax=docker/dockerfile:1

FROM golang:1.22-bookworm AS build

WORKDIR /app

COPY go.mod ./

COPY . ./
RUN CGO_ENABLED=0 go build -o yamlak

FROM gcr.io/distroless/base-debian10

WORKDIR /

COPY --from=build app/yamlak /yamlak

ENTRYPOINT ["/yamlak"]

0 comments on commit 03e19df

Please sign in to comment.