Skip to content

Push image to GHCR #167

Push image to GHCR

Push image to GHCR #167

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.22'
- name: Build Docker Image
run: docker build . -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.22
test:
name: Run Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16.3
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.22'
- 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