forked from day50-dev/Petsitter
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (85 loc) · 2.8 KB
/
Copy pathtest.yml
File metadata and controls
91 lines (85 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: test-and-publish
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
env:
IMAGE_NAME: ghcr.io/coderdoubleflower/sub2apiauditer
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- run: python -m pip install -e '.[test]'
- run: pytest -q
frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: node --check src/sub2api_auditer/static/app.js
- run: node --test tests/test_frontend.cjs
docker-build:
needs: [pytest, frontend]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# Serialize main publications; an older queued run must not overwrite latest.
concurrency:
group: ghcr-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: Check current main revision
id: revision
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ github.token }}
run: |
current=$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/heads/main" --jq .object.sha)
if [ "$current" = "$GITHUB_SHA" ]; then
echo 'current=true' >> "$GITHUB_OUTPUT"
else
echo 'current=false' >> "$GITHUB_OUTPUT"
echo 'Skip obsolete main revision; do not overwrite latest.' >> "$GITHUB_STEP_SUMMARY"
fi
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: steps.revision.outputs.current == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ steps.revision.outputs.current == 'true' }}
type=sha,format=short
- name: Build and optionally publish image
if: github.event_name == 'pull_request' || steps.revision.outputs.current == 'true'
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ steps.revision.outputs.current == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max