Skip to content

Commit

Permalink
chore: setup docker & cicd github action (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldiwildan77 authored Dec 10, 2023
1 parent 57e3778 commit a48b52a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 39 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Donut Release Build

on:
release:
types: [published]

workflow_dispatch:
inputs:
tag:
description: 'Tag version'
required: true

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

- name: Setup go version
uses: actions/setup-go@v3
with:
go-version: '1.21.0'

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_GITHUB_TOKEN }}

- name: Set output release tag
id: release
if: github.event_name == 'release'
run: echo ::set-output name=tag::${{ github.event.release.tag_name }}

- name: Set output release tag
id: dispatch
if: github.event_name == 'workflow_dispatch'
run: echo ::set-output name=tag::${{ github.event.inputs.tag }}

- name: Build docker image for donut
run: |
RELEASE_VERSION=${{ github.event.release.tag_name }}
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
RELEASE_VERSION=${{ github.event.inputs.tag }}
fi
RELEASE_VERSION="${RELEASE_VERSION#?}"
echo $RELEASE_VERSION
go version
docker build . -t ghcr.io/mocha-bot/donut:$RELEASE_VERSION -t ghcr.io/mocha-bot/donut:latest
docker push ghcr.io/mocha-bot/donut:$RELEASE_VERSION
docker push ghcr.io/mocha-bot/donut:latest
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM golang:1.21.0-alpine3.18 as builder

RUN apk update && apk upgrade && \
apk --no-cache --update add git make

WORKDIR /app

COPY . .

RUN go mod tidy && \
go mod download && \
go build -v -o engine && \
chmod +x engine

## Distribution
FROM alpine:latest

# Install dependencies
RUN apk update && apk upgrade && \
apk --no-cache --update add ca-certificates tzdata && \
mkdir donut

# Install Doppler CLI
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/[email protected] && \
echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories && \
apk add doppler

WORKDIR /donut

COPY --from=builder /app/engine /donut
40 changes: 1 addition & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,4 @@
## Description

A way to drink a mocha with a donut.

## Example Result

```md
Start...
Bob paired with Grace
Frank paired with Alice
Eve paired with David
Charlie paired with Harry

Do calls...
Alice called Bob
Charlie called David
Eve called Frank

Add person...
Added Ivan
Added Goldi
Added Samde

RePair...
Harry paired with Goldi
Ivan paired with Grace
3-way call Samde

Remove person...
Removed Ivan

RePair...
Goldi paired with Samde
Grace paired with Harry

Print...
People: Alice, Bob, Charlie, David, Eve, Frank, Grace, Harry, Goldi, Samde
PeopleMap: map[Alice:true Bob:true Charlie:true David:true Eve:true Frank:true Goldi:false Grace:false Harry:false Samde:false]
MatchMap: map[Alice:Frank Bob:Grace Charlie:Harry David:Eve Eve:David Frank:Alice Goldi:Samde Grace:Harry Harry:Grace Ivan:Grace Samde:Goldi]
Completed: Alice, Bob, Charlie, David, Eve, Frank
Remaining: Grace, Harry, Goldi, Samde
```
Enjoy the 1 on 1 session with your buddies.

0 comments on commit a48b52a

Please sign in to comment.