fix: use origin/main workflow with env vars for registry credentials
Resolved merge conflicts by using current origin/main workflow which: - Includes test job (npm ci + npm test) - Has delete old latest image step - Uses --build-arg for COMMIT_SHA - Uses env vars for registry credentials (FORGEJO_REGISTRY_USER/TOKEN) All features from main preserved, registry login fixed.
This commit is contained in:
@@ -1,26 +1,42 @@
|
|||||||
name: Build & Push Portfolio Image
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
env:
|
||||||
build-push:
|
|
||||||
runs-on: golang
|
|
||||||
container:
|
|
||||||
image: docker:27-cli
|
|
||||||
volumes:
|
|
||||||
- /docker-certs/client:/docker-certs/client:ro
|
|
||||||
env:
|
|
||||||
DOCKER_HOST: tcp://localhost:2376
|
|
||||||
DOCKER_TLS_VERIFY: "1"
|
|
||||||
DOCKER_CERT_PATH: /docker-certs/client
|
|
||||||
REGISTRY: forgejo.riotpiao.com
|
REGISTRY: forgejo.riotpiao.com
|
||||||
IMAGE: forgejo.riotpiao.com/rock/portfolio
|
IMAGE: forgejo.riotpiao.com/rock/portfolio
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: node
|
||||||
steps:
|
steps:
|
||||||
- name: Install git
|
- name: Install Node.js for actions runtime
|
||||||
run: apk add --no-cache git nodejs
|
run: apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: npm test -- --run 2>&1 || echo "Tests completed"
|
||||||
|
|
||||||
|
build-push:
|
||||||
|
name: Build & Push Image
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
runs-on: node
|
||||||
|
steps:
|
||||||
|
- name: Install Node.js and Docker
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y nodejs docker.io
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -64,4 +80,8 @@ jobs:
|
|||||||
docker push "${IMAGE}:latest"
|
docker push "${IMAGE}:latest"
|
||||||
echo "✓ Image pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
echo "✓ Image pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||||
|
|
||||||
|
- name: Prune unused images
|
||||||
|
run: |
|
||||||
|
docker image prune -a --force 2>&1 | tail -3 || true
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user