diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml deleted file mode 100644 index 6350eeb7f..000000000 --- a/.github/workflows/ghcr.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: GHCR - -on: - workflow_dispatch: - push: - branches: [master] - tags: ["v*.*.*"] - -env: - REGISTRY: ghcr.io - -jobs: - build-push-image: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - strategy: - matrix: - image: [nginx, service] - - steps: - - name: Checkout repository - uses: actions/checkout@v5 - with: - fetch-depth: 0 - fetch-tags: true - submodules: recursive - - - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@v4 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Show Docker Context - run: ./test/check-docker-context.sh --report - - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v6 - with: - images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/central-${{ matrix.image }} - - - name: Set up QEMU emulator for multi-arch images - uses: docker/setup-qemu-action@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4 - - - name: Build and push ${{ matrix.image }} Docker image - uses: docker/build-push-action@v7 - with: - file: ${{ matrix.image }}.dockerfile - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: 'linux/amd64,linux/arm64' diff --git a/.github/workflows/test.yml b/.github/workflows/main.yml similarity index 59% rename from .github/workflows/test.yml rename to .github/workflows/main.yml index 656db878a..d15cef75b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/main.yml @@ -1,8 +1,15 @@ -name: Test +name: Test, Build, Publish on: push: pull_request: + workflow_dispatch: + inputs: + publish_image: + description: 'Publish image to registry?' + required: true + type: boolean + default: false jobs: test-misc: # quick, simple checks @@ -85,3 +92,58 @@ jobs: - run: ./test/test-images.sh - if: always() run: docker compose logs + build-push-image: + if: | + (github.event_name == 'workflow_dispatch' && inputs.publish_image == true) || + (github.event_name != 'workflow_dispatch' && ( + github.ref == 'refs/heads/master' || + startsWith(github.ref, 'refs/tags/v') + )) + needs: + - test-images + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + matrix: + image: [nginx, service] + env: + REGISTRY: ghcr.io + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + fetch-tags: true + submodules: recursive + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v4 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Show Docker Context + run: ./test/check-docker-context.sh --report + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v6 + with: + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/central-${{ matrix.image }} + + - name: Set up QEMU emulator for multi-arch images + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Build and push ${{ matrix.image }} Docker image + uses: docker/build-push-action@v7 + with: + file: ${{ matrix.image }}.dockerfile + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: 'linux/amd64,linux/arm64'