-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} | ||
|
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
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 ./... |
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
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"] |