Setup CI workflows for both pull requests and main branch (switch to environment for publishing) #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub CI | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
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 | |
test: | |
needs: generate-jobs | |
strategy: ${{ fromJson(needs.generate-jobs.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 }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
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 |