CI native clone + docker
This commit is contained in:
+74
-33
@@ -1,5 +1,6 @@
|
||||
# Gitea Actions — Copyparty Content Tag CI
|
||||
# Triggers: push, PR, tag builds
|
||||
# Fully Docker-based: no host-side tooling (no Node.js, no git) required.
|
||||
# Every step runs inside a Docker container with its own dependencies.
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -9,78 +10,118 @@ on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
env:
|
||||
WS: /ws
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# --- TSV Unit Tests (no network) ---
|
||||
# Shared workspace volume so containers can pass files between steps
|
||||
container:
|
||||
image: alpine:latest
|
||||
|
||||
steps:
|
||||
# --- Clone repo inside an Alpine container with git ---
|
||||
- name: Checkout Source
|
||||
run: |
|
||||
apk add --no-cache git
|
||||
mkdir -p $WS && cd $WS
|
||||
git clone $GITEA_REPOSITORY_URL .
|
||||
git checkout $GITEA_REVISION
|
||||
|
||||
# --- TSV Unit Tests inside Node container ---
|
||||
- name: TSV Unit Tests
|
||||
run: |
|
||||
node tests/tsv-test.js
|
||||
docker run --rm \
|
||||
-v $WS:$WS \
|
||||
-w $WS/tests \
|
||||
node:22-slim \
|
||||
node tsv-test.js
|
||||
|
||||
# --- Copyparty API Sanity Tests ---
|
||||
- name: Start Copyparty Test Server
|
||||
- name: Prepare Test Data & Config
|
||||
run: |
|
||||
mkdir -p /tmp/copyparty-test-data
|
||||
docker run -d --name cp-test \
|
||||
-p 8086:8086 \
|
||||
-v /tmp/copyparty-test-data:/data \
|
||||
-e CP_CONFIG=/tmp/copyparty-test-config.yaml \
|
||||
9001/copyparty:latest \
|
||||
|| echo "Container already running"
|
||||
apk add --no-cache curl
|
||||
mkdir -p /tmp/copyparty-data/public /tmp/copyparty-data/private/user
|
||||
|
||||
# Write test config
|
||||
cat > /tmp/copyparty-test-config.yaml <<'EOF'
|
||||
cat > /tmp/copyparty-config.ini <<'EOF'
|
||||
[global]
|
||||
p: 8086
|
||||
p = 8086
|
||||
[accounts]
|
||||
user:12345
|
||||
user = 12345
|
||||
[/public/]
|
||||
/data/public
|
||||
accs:
|
||||
r: *
|
||||
r = *
|
||||
[/private/user]
|
||||
/data/private/user
|
||||
accs:
|
||||
A: user
|
||||
A = user
|
||||
EOF
|
||||
|
||||
- name: Start Copyparty Test Server
|
||||
run: |
|
||||
apk add --no-cache curl
|
||||
docker run -d --name cp-test \
|
||||
-p 8086:8086 \
|
||||
-v /tmp/copyparty-data:/data \
|
||||
-v /tmp/copyparty-config.ini:/etc/copyparty/config.ini:ro \
|
||||
-e CP_CONFIG=/etc/copyparty/config.ini \
|
||||
9001/copyparty:latest \
|
||||
|| { docker restart cp-test; true }
|
||||
|
||||
# Wait for server to be ready
|
||||
for i in $(seq 1 30); do
|
||||
curl -sf http://localhost:8086/?ls >/dev/null 2>&1 && break
|
||||
sleep 2
|
||||
done
|
||||
|
||||
- name: API Sanity Tests
|
||||
- name: API Sanity Tests (in job container)
|
||||
run: |
|
||||
bash tests/api-tests.sh
|
||||
apk add --no-cache curl jq bash
|
||||
cd $WS/tests && bash api-tests.sh
|
||||
|
||||
- name: Cleanup Test Container
|
||||
if: always()
|
||||
run: docker stop cp-test && docker rm cp-test || true
|
||||
run: |
|
||||
apk add --no-cache curl
|
||||
docker stop cp-test && docker rm cp-test || true
|
||||
|
||||
# --- Release Build ---
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'release'
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
container:
|
||||
image: alpine:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Source
|
||||
run: |
|
||||
apk add --no-cache git
|
||||
mkdir -p $WS && cd $WS
|
||||
git clone $GITEA_REPOSITORY_URL .
|
||||
git checkout $GITEA_REVISION
|
||||
|
||||
# --- Build release artifact inside Alpine container ---
|
||||
- name: Build Release Artifact
|
||||
run: |
|
||||
mkdir -p release/copyparty-content-tag
|
||||
cp src/*.html src/*.css src/*.js release/copyparty-content-tag/
|
||||
cd release
|
||||
apk add --no-cache tar coreutils
|
||||
mkdir -p /release/copyparty-content-tag
|
||||
cp src/*.html src/*.css src/*.js /release/copyparty-content-tag/
|
||||
cd /release
|
||||
sha256sum copyparty-content-tag/* > checksums.sha256
|
||||
tar czf copyparty-content-tag.tar.gz copyparty-content-tag/
|
||||
|
||||
# --- Upload to Gitea Release via API (no JS action needed) ---
|
||||
- name: Upload Release Artifact
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITEA_TOKEN }}
|
||||
file: release/*.tar.gz
|
||||
tag: ${{ github.ref }}
|
||||
file_glob: true
|
||||
run: |
|
||||
apk add --no-cache curl
|
||||
TAG=$(echo "$GITEA_REF" | sed 's|refs/tags||')
|
||||
curl -sSf -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @/release/copyparty-content-tag.tar.gz \
|
||||
"$GITEA_SERVER_URL/api/repos/$GITEA_REPOSITORY/releases.attachments?name=copyparty-content-tag.tar.gz&tag=$TAG"
|
||||
|
||||
Reference in New Issue
Block a user