02a108a58e
The CI workflow previously only triggered on push to master, meaning PRs were not tested before merge. Add pull_request trigger for the test job while restricting the Docker build+push job to push events only. Closes leeworks-agents/gitea-mobile#204 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49 lines
1.2 KiB
YAML
49 lines
1.2 KiB
YAML
name: Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.22'
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Run tests
|
|
run: go test -race ./...
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: gitea.event_name == 'push'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login gitea.leeworks.dev \
|
|
-u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
|
|
|
- name: Build and push Docker image
|
|
run: |
|
|
TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
|
SHA=$(echo ${{ gitea.sha }} | cut -c1-7)
|
|
TAG="${TIMESTAMP}-${SHA}"
|
|
docker build -t gitea.leeworks.dev/0xwheatyz/gitea-mobile:${TAG} .
|
|
docker tag gitea.leeworks.dev/0xwheatyz/gitea-mobile:${TAG} \
|
|
gitea.leeworks.dev/0xwheatyz/gitea-mobile:latest
|
|
docker push gitea.leeworks.dev/0xwheatyz/gitea-mobile:${TAG}
|
|
docker push gitea.leeworks.dev/0xwheatyz/gitea-mobile:latest
|