Files
personal-website/.gitea/workflows/build.yml
Stan Runge 40ff6f795b
All checks were successful
build / build (push) Successful in 40s
build / deploy (push) Successful in 7s
ci: pick dir by branch for staging/prod deploy
2026-08-26 04:13:16 +00:00

46 lines
1.2 KiB
YAML

name: build
on:
push:
branches: [main, staging]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: git.stanrunge.dev
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: .
push: true
tags: git.stanrunge.dev/stan/personal-website:${{ github.sha }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: setup key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H 172.17.0.1 >> ~/.ssh/known_hosts
- name: pick target
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "DIR=/opt/personal-website" >> $GITHUB_ENV
else
echo "DIR=/opt/personal-website-staging" >> $GITHUB_ENV
fi
- name: deploy
run: |
ssh deploy@172.17.0.1 "echo IMAGE_TAG=${{ github.sha }} | sudo tee $DIR/.env && sudo docker compose -f $DIR/compose.prod.yml up -d"