Mensa-API/.github/workflows/gotestnbuild.yml

52 lines
1.2 KiB
YAML
Raw Normal View History

2024-09-20 15:32:16 +00:00
name: Go Tests & Build
on:
push:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
2024-09-20 15:53:56 +00:00
IMAGE_NAME: leroid-hub/Mensa-API:latest
2024-09-20 15:32:16 +00:00
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 }} \
2024-09-20 15:50:36 +00:00
-H "Title: Github ${{ env.IMAGE_NAME }}" \
2024-09-20 15:32:16 +00:00
-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 }}