Skip to content

ci: add server build #13

ci: add server build

ci: add server build #13

Workflow file for this run

name: ci
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Run tests
run: go test -v ./...
build-server:
runs-on: ubuntu-latest
needs:
- test
env:
# Check if this is not a fork as forks cannot push to ghcr
IS_NOT_FORK: ${{ github.repository == github.event.repository.full_name }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to ghcr
if: ${{ env.IS_NOT_FORK == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.actor }}/tunnel-server
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ env.IS_NOT_FORK == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
ok:
runs-on: ubuntu-latest
needs:
- test
- build-server
if: always()
steps:
- run: |
if ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}; then
echo "One or more required jobs failed"
exit 1
fi
echo "ok"