Resolve remaining merge conflict: accept PR changes (remove Charon.code-workspace)
This commit is contained in:
97
.github/workflows/docker-publish.yml
vendored
97
.github/workflows/docker-publish.yml
vendored
@@ -6,8 +6,7 @@ on:
|
||||
- main
|
||||
- development
|
||||
- feature/beta-release
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
# Note: Tags are handled by release-goreleaser.yml to avoid duplicate builds
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -18,7 +17,7 @@ on:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/cpmp
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/charon
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
@@ -84,13 +83,24 @@ jobs:
|
||||
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' caddy:2-alpine)
|
||||
echo "image=$DIGEST" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Choose Registry Token
|
||||
if: github.event_name != 'pull_request' && steps.skip.outputs.skip_build != 'true'
|
||||
run: |
|
||||
if [ -n "${{ secrets.CHARON_TOKEN }}" ]; then
|
||||
echo "Using CHARON_TOKEN" >&2
|
||||
echo "REGISTRY_PASSWORD=${{ secrets.CHARON_TOKEN }}" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Using CPMP_TOKEN fallback" >&2
|
||||
echo "REGISTRY_PASSWORD=${{ secrets.CPMP_TOKEN }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Log in to Container Registry
|
||||
if: github.event_name != 'pull_request' && steps.skip.outputs.skip_build != 'true'
|
||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.CPMP_TOKEN }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels)
|
||||
if: steps.skip.outputs.skip_build != 'true'
|
||||
@@ -102,9 +112,6 @@ jobs:
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/development' }}
|
||||
type=raw,value=beta,enable=${{ github.ref == 'refs/heads/feature/beta-release' }}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=raw,value=pr-${{ github.ref_name }},enable=${{ github.event_name == 'pull_request' }}
|
||||
type=sha,format=short,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
@@ -184,6 +191,9 @@ jobs:
|
||||
if: needs.build-and-push.outputs.skip_build != 'true' && github.event_name != 'pull_request'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
|
||||
- name: Normalize image name
|
||||
run: |
|
||||
raw="${{ github.repository_owner }}/${{ github.event.repository.name }}"
|
||||
@@ -202,38 +212,47 @@ jobs:
|
||||
echo "tag=sha-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Choose Registry Token
|
||||
run: |
|
||||
if [ -n "${{ secrets.CHARON_TOKEN }}" ]; then
|
||||
echo "Using CHARON_TOKEN" >&2
|
||||
echo "REGISTRY_PASSWORD=${{ secrets.CHARON_TOKEN }}" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Using CPMP_TOKEN fallback" >&2
|
||||
echo "REGISTRY_PASSWORD=${{ secrets.CPMP_TOKEN }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.CPMP_TOKEN }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Pull Docker image
|
||||
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
|
||||
|
||||
- name: Run container
|
||||
- name: Create Docker Network
|
||||
run: docker network create charon-test-net
|
||||
|
||||
- name: Run Upstream Service (whoami)
|
||||
run: |
|
||||
docker run -d \
|
||||
--name whoami \
|
||||
--network charon-test-net \
|
||||
traefik/whoami
|
||||
|
||||
- name: Run Charon Container
|
||||
run: |
|
||||
docker run -d \
|
||||
--name test-container \
|
||||
--network charon-test-net \
|
||||
-p 8080:8080 \
|
||||
-p 80:80 \
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
|
||||
|
||||
- name: Test health endpoint (retries)
|
||||
run: |
|
||||
set +e
|
||||
for i in $(seq 1 30); do
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/v1/health || echo "000")
|
||||
if [ "$code" = "200" ]; then
|
||||
echo "✅ Health check passed on attempt $i"
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $i/30: health not ready (code=$code); waiting..."
|
||||
sleep 2
|
||||
done
|
||||
echo "❌ Health check failed after retries"
|
||||
docker logs test-container || true
|
||||
exit 1
|
||||
- name: Run Integration Test
|
||||
run: ./scripts/integration-test.sh
|
||||
|
||||
- name: Check container logs
|
||||
if: always()
|
||||
@@ -241,7 +260,10 @@ jobs:
|
||||
|
||||
- name: Stop container
|
||||
if: always()
|
||||
run: docker stop test-container && docker rm test-container
|
||||
run: |
|
||||
docker stop test-container whoami || true
|
||||
docker rm test-container whoami || true
|
||||
docker network rm charon-test-net || true
|
||||
|
||||
- name: Create test summary
|
||||
if: always()
|
||||
@@ -249,4 +271,27 @@ jobs:
|
||||
echo "## 🧪 Docker Image Test Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Image**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Health Check**: ${{ job.status == 'success' && '✅ Passed' || '❌ Failed' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Integration Test**: ${{ job.status == 'success' && '✅ Passed' || '❌ Failed' }}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
trivy-pr-app-only:
|
||||
name: Trivy (PR) - App-only
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build image locally for PR
|
||||
run: |
|
||||
docker build -t charon:pr-${{ github.sha }} .
|
||||
|
||||
- name: Extract `charon` binary from image
|
||||
run: |
|
||||
CONTAINER=$(docker create charon:pr-${{ github.sha }})
|
||||
docker cp ${CONTAINER}:/app/charon ./charon_binary || true
|
||||
docker rm ${CONTAINER} || true
|
||||
|
||||
- name: Run Trivy filesystem scan on `charon` (fail PR on HIGH/CRITICAL)
|
||||
run: |
|
||||
docker run --rm -v $HOME/.cache/trivy:/root/.cache/trivy -v $PWD:/workdir aquasec/trivy:latest fs --exit-code 1 --severity CRITICAL,HIGH /workdir/charon_binary
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user