diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml new file mode 100644 index 0000000..0ddf306 --- /dev/null +++ b/.github/workflows/common.yml @@ -0,0 +1,44 @@ +name: Common jobs workflow + +on: + workflow_call: + outputs: + strategy: + description: "Matrix strategy for generating jobs" + value: ${{ jobs.generate-jobs.outputs.strategy }} + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' + +jobs: + + verify-templates: + name: Check For Uncomitted Changes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Download libraries + run: ./download-libs.sh + - name: Apply Templates + run: ./apply-templates.sh + - name: Check Git Status + run: | + status="$(git status --short)" + [ -z "$status" ] + + generate-jobs: + name: Generate Jobs + needs: verify-templates + runs-on: ubuntu-latest + outputs: + strategy: ${{ steps.generate-jobs.outputs.strategy }} + steps: + - uses: actions/checkout@v3 + - uses: docker-library/bashbrew@HEAD + - id: generate-jobs + name: Generate Jobs + run: | + strategy="$(cat versions-ci-json.lock)" + echo "strategy=$strategy" >> "$GITHUB_OUTPUT" + jq . <<<"$strategy" # sanity check / debugging aid diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e0d80c..84b82a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,51 +1,21 @@ -name: GitHub CI +name: Main branch workflow on: push: branches: - 'main' -defaults: - run: - shell: 'bash -Eeuo pipefail -x {0}' - jobs: - verify-templates: - name: Check For Uncomitted Changes - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Download libraries - run: ./download-libs.sh - - name: Apply Templates - run: ./apply-templates.sh - - name: Check Git Status - run: | - status="$(git status --short)" - [ -z "$status" ] - - generate-jobs: - name: Generate Jobs - needs: verify-templates - runs-on: ubuntu-latest - outputs: - strategy: ${{ steps.generate-jobs.outputs.strategy }} - steps: - - uses: actions/checkout@v3 - - uses: docker-library/bashbrew@HEAD - - id: generate-jobs - name: Generate Jobs - run: | - strategy="$(cat versions-ci-json.lock)" - echo "strategy=$strategy" >> "$GITHUB_OUTPUT" - jq . <<<"$strategy" # sanity check / debugging aid + common: + uses: ./.github/workflows/common.yml test: - needs: generate-jobs - strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} + needs: common + strategy: ${{ fromJson(needs.common.outputs.strategy) }} name: ${{ matrix.name }} runs-on: ${{ matrix.os }} + environment: publishing steps: - uses: actions/checkout@v3 - name: Prepare Environment @@ -66,4 +36,5 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push ${{ matrix.name }} + if: github.ref == 'refs/heads/master' run: docker push --all-tags aaronmchale/drupal-php diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..8b60e9e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,29 @@ +name: PR workflow + +on: + pull_request: + +jobs: + + common: + uses: ./.github/workflows/common.yml + + test: + needs: common + strategy: ${{ fromJson(needs.common.outputs.strategy) }} + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Prepare Environment + run: ${{ matrix.runs.prepare }} + - name: Pull Dependencies + run: ${{ matrix.runs.pull }} + - name: Build ${{ matrix.name }} + run: ${{ matrix.runs.build }} + - name: History ${{ matrix.name }} + run: ${{ matrix.runs.history }} + - name: Test ${{ matrix.name }} + run: ${{ matrix.runs.test }} + - name: '"docker images"' + run: ${{ matrix.runs.images }}