Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CI workflows for both pull requests and main branch (switch to environment for publishing) #1

Merged
merged 7 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 7 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
29 changes: 29 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading