From ad8222633e0363ae4394cc907ba7490f8f1988d4 Mon Sep 17 00:00:00 2001 From: Jan <45685070+LeRoid-hub@users.noreply.github.com> Date: Sat, 2 Nov 2024 19:22:28 +0100 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..35cf85e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,54 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Test & Build + +on: + push: + branches: [ "main" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + IMAGE_NAME: leroid-hub/humiditycalc:latest + PAT: ${{ secrets.PAT }} + +jobs: + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.23' + + - name: Build + run: go build -v ./... + - name: Actions Ntfy + run: | + curl \ + -u ${{ secrets.NTFY_CRED }} \ + -H "Title: Github humiditycalc" \ + -H "Content-Type: text/plain" \ + -d $'Repo: ${{ github.repository }}\nCommit: ${{ github.sha }} - ${{ github.event.head_commit.message }}\nRef: ${{ github.ref }}\nStatus: ${{ job.status}}' \ + ${{ secrets.NTFY_URL }} + +# - name: Test +# run: go test -v ./... + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Login + run: | + echo ${{ env.PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Build and Publish + run: | + docker build . --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}