mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-09 12:16:50 +00:00
This update enhances the CI workflow by adding steps to set up Go using the version specified in go.mod, add the Go bin directory to the PATH, and install the templ code generation tool. These additions ensure that Go-based tooling is available for subsequent CI steps.
83 lines
2 KiB
YAML
83 lines
2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- "**"
|
|
|
|
jobs:
|
|
checks:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NAME: rentease
|
|
PORT: 8000
|
|
DB_USER: ci
|
|
DB_NAME: villafleurie
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Add Go bin to PATH
|
|
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install templ
|
|
run: go install github.com/a-h/templ/cmd/templ@v0.3.960
|
|
|
|
- name: Install golangci-lint
|
|
run: |
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
|
|
| sh -s -- -b $(go env GOPATH)/bin latest
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build dev image (cached)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile.dev
|
|
tags: ${{ env.NAME }}:dev
|
|
load: true
|
|
cache-from: type=gha,scope=dev
|
|
cache-to: type=gha,scope=dev,mode=max
|
|
|
|
- name: Start dev container (background)
|
|
run: |
|
|
docker run -d \
|
|
--name ${NAME} \
|
|
-v "$GITHUB_WORKSPACE":/app \
|
|
-v /app/tmp \
|
|
${NAME}:dev sleep infinity
|
|
|
|
- name: Make format
|
|
run: make format
|
|
|
|
- name: Make lint
|
|
run: make lint
|
|
|
|
- name: Make test
|
|
run: make test
|
|
|
|
- name: Stop container
|
|
if: always()
|
|
run: |
|
|
docker logs ${NAME} || true
|
|
docker stop ${NAME} || true
|
|
|
|
- name: Build production image (cached, push only)
|
|
if: github.event_name == 'push'
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
tags: ${{ env.NAME }}:latest
|
|
cache-from: type=gha,scope=prod
|
|
cache-to: type=gha,scope=prod,mode=max
|