Skip to content

fix GHCR build

fix GHCR build #260

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build and Push to GHCR
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23'
- name: Build Docker Image
run: |
git fetch --unshallow --tags
BUILDTIME=$(date -R)
docker build --build-arg VERSION=$(git describe --tags --always) --build-arg BUILDTIME='$BUILDTIME' . -f build/Dockerfile -t ghcr.io/${{ github.repository }}:latest
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker Image
run: docker push ghcr.io/${{ github.repository }}:latest
check-dependencies:
name: Check dependencies with nancy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- name: WriteGoList
run: go list -json -m all > go.list
- name: Nancy
uses: sonatype-nexus-community/nancy-github-action@main
continue-on-error: true
lint-code:
name: Lint with golangci-lint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
go_version: 1.23
lint-oapi:
name: Run Spectral
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stoplightio/spectral-action@latest
with:
file_glob: 'api/.yaml'
spectral_ruleset: "configs/spectral/spectral.yaml"
test:
name: Run Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16.4
env:
POSTGRES_DB: ctf01d_training_platform_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PGPORT: 4112
ports:
- 4112:4112
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.23'
- name: Install Dependencies
run: make install
- name: Wait for PostgreSQL
run: until pg_isready -h localhost -p 4112 -U postgres; do sleep 1; done
- name: Run Tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost:4112/ctf01d_training_platform_test?sslmode=disable
run: go test -v ./test/server_integration_test.go