From 54c7a3c67065f984143254faa9b559779192596c Mon Sep 17 00:00:00 2001 From: James Coleman Date: Sat, 30 Nov 2024 10:42:18 -0600 Subject: [PATCH] Add docker file and other github actions --- .github/workflows/publish_docker_image.yml | 10 ++++---- .github/workflows/release.yaml | 29 ++++++++++++++++++++++ .github/workflows/test_golang.yaml | 21 ++++++++++++++++ Dockerfile | 16 ++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test_golang.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/publish_docker_image.yml b/.github/workflows/publish_docker_image.yml index 5a2f0a3..dfc8138 100644 --- a/.github/workflows/publish_docker_image.yml +++ b/.github/workflows/publish_docker_image.yml @@ -14,28 +14,28 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v3 - + - name: Log in to Docker Hub uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - + - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: images: | - grmrgecko/osc-mqtt-bridge + grmrgecko/midi-request-trigger ghcr.io/${{ github.repository }} - + - name: Build and push Docker images uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..1d1dd80 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +on: + release: + types: [created] + +permissions: + contents: write + packages: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v4 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test_golang.yaml b/.github/workflows/test_golang.yaml new file mode 100644 index 0000000..9cef003 --- /dev/null +++ b/.github/workflows/test_golang.yaml @@ -0,0 +1,21 @@ +name: Go package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b13c4b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.20 + +# Build app +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY *.go ./ +RUN go build -o /midi-request-trigger +WORKDIR /app +RUN rm -Rf /app; mkdir /etc/midi-request-trigger + +# Configuration volume +VOLUME ["/etc/midi-request-trigger"] + +# Command +CMD ["/midi-request-trigger"]