CI and Deployment (#1)
Reviewed-on: https://git.ts.mattnite.net/mattnite/forgejo-tickets/pulls/1
This commit is contained in:
parent
c7bdb3b66e
commit
4fa62de794
|
|
@ -0,0 +1,36 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.23'
|
||||
|
||||
- name: Run tests
|
||||
run: go test ./...
|
||||
|
||||
build:
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
apt-get update && apt-get install -y curl
|
||||
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz \
|
||||
| tar xz --strip-components=1 -C /usr/local/bin docker/docker
|
||||
|
||||
- name: Build image
|
||||
run: docker build -t forgejo-tickets:test .
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
concurrency:
|
||||
group: deploy-main
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
apt-get update && apt-get install -y curl
|
||||
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz \
|
||||
| tar xz --strip-components=1 -C /usr/local/bin docker/docker
|
||||
|
||||
- name: Wait for Docker
|
||||
run: |
|
||||
timeout=30
|
||||
elapsed=0
|
||||
while ! docker info >/dev/null 2>&1; do
|
||||
[ $elapsed -ge $timeout ] && echo "Docker not ready" && exit 1
|
||||
sleep 2
|
||||
elapsed=$((elapsed + 2))
|
||||
done
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
IMAGE="registry.ts.mattnite.net/forgejo-tickets"
|
||||
docker build -t "${IMAGE}:${GITHUB_SHA}" -t "${IMAGE}:latest" .
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
IMAGE="registry.ts.mattnite.net/forgejo-tickets"
|
||||
docker push "${IMAGE}:${GITHUB_SHA}"
|
||||
docker push "${IMAGE}:latest"
|
||||
|
||||
- name: Update infra
|
||||
uses: https://git.ts.mattnite.net/mattnite/infra/actions/update-image@main
|
||||
with:
|
||||
updates: |
|
||||
forgejo-tickets ${{ github.sha }} tickets/tickets.hcl
|
||||
forgejo_token: ${{ secrets.INFRA_API_TOKEN }}
|
||||
Loading…
Reference in New Issue