From 69392102fb18d47f56545d010c417c31834af865 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Wed, 19 Mar 2025 10:41:37 -0700 Subject: [PATCH] Combined workflow files --- .../{test-suite.yaml => ci-suite.yaml} | 47 +++++++++++++++++-- .github/workflows/publish-image.yaml | 41 ---------------- 2 files changed, 42 insertions(+), 46 deletions(-) rename .github/workflows/{test-suite.yaml => ci-suite.yaml} (74%) delete mode 100644 .github/workflows/publish-image.yaml diff --git a/.github/workflows/test-suite.yaml b/.github/workflows/ci-suite.yaml similarity index 74% rename from .github/workflows/test-suite.yaml rename to .github/workflows/ci-suite.yaml index 31dbedf..ea2fe0b 100644 --- a/.github/workflows/test-suite.yaml +++ b/.github/workflows/ci-suite.yaml @@ -1,4 +1,4 @@ -name: Directory Lister Test Suite +name: Directory Lister CI on: [push, pull_request, workflow_dispatch] jobs: @@ -28,7 +28,7 @@ jobs: coding-standards: name: Coding Standards - runs-on: 'ubuntu-latest' + runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -48,7 +48,7 @@ jobs: static-analysis: name: Static Analysis - runs-on: 'ubuntu-latest' + runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -68,7 +68,7 @@ jobs: tests: name: Tests - runs-on: 'ubuntu-latest' + runs-on: ubuntu-latest services: redis: @@ -109,11 +109,48 @@ jobs: - name: Run Tests run: app/vendor/bin/phpunit --coverage-text + build-and-push-image: + name: Build & Push Image + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + needs: [asset-compilation, coding-standards, static-analysis, tests] + + env: + DOCKER_HUB_USER: phlak + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Extract Metadata + id: extract-metadata + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_HUB_USER }}/directory-lister + tags: | + type=raw,value=latest + type=ref,event=tag + + - name: Build & Push Image + uses: docker/build-push-action@v6 + with: + file: Dockerfile.prod + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.extract-metadata.outputs.tags }} + labels: ${{ steps.extract-metadata.outputs.labels }} + release: name: Create Release - runs-on: 'ubuntu-latest' + runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') needs: [asset-compilation, coding-standards, static-analysis, tests] + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-image.yaml deleted file mode 100644 index 2cfa308..0000000 --- a/.github/workflows/publish-image.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: Publish Image - -on: - push: - branches: ['master'] - tags: ['*'] - -env: - DOCKER_HUB_USER: phlak - -jobs: - build-and-push: - name: Build & Push - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ env.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: Extract Metadata - id: extract-metadata - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKER_HUB_USER }}/directory-lister - tags: | - type=raw,value=latest - type=ref,event=tag - - - name: Build & Push Image - uses: docker/build-push-action@v6 - with: - file: Dockerfile.prod - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.extract-metadata.outputs.tags }} - labels: ${{ steps.extract-metadata.outputs.labels }}