Skip to content

Commit

Permalink
ci: refactor workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
schuer committed Dec 10, 2023
1 parent 7c849ab commit 7073f6f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 34 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml → .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Generate

on:
pull_request:
Expand All @@ -12,13 +12,13 @@ concurrency:
cancel-in-progress: true

jobs:
build:
name: Build
generate:
name: Generate image files from source
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Ref is required if auto-commit action is used in pull requests.
# https://github.com/stefanzweifel/git-auto-commit-action#checkout-the-correct-branch
Expand All @@ -32,17 +32,17 @@ jobs:
with:
deno-version: "^1"

- name: Run build
- name: Run generator script
run: deno task start

- name: Auto-commit changed files
# Automatically commit files which have been changed during the workflow run and push changes back
# to remote repository.
# https://github.com/stefanzweifel/git-auto-commit-action
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'build: rRRR!'
commit_message: 'GenerRRRRR-ate image files from source!'
commit_user_name: 'FriendsOfREDAXO-T'
commit_user_email: '[email protected]'
commit_author: 'FriendsOfREDAXO-T <[email protected]>'
file_pattern: 'builds/**/*'
file_pattern: 'images/**/*'
58 changes: 58 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Publish

on:
push:
branches:
- 'main'
paths:
- 'images/**/*'
# add workflow dispatch to manually publish the current images
workflow_dispatch

concurrency:
# Cancel in-progress jobs if a new job is trigged by a commit from the same branch
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
collect:
name: Collect images from directories
runs-on: ubuntu-latest
outputs:
IMAGES: ${{ steps.images.outputs.directories }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Collect images from directories
id: images
run: |
# install tree and jq
sudo apt update && sudo apt install -y tree jq
# change to images directory
cd images
# collect images
echo "directories=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name)')" >> $GITHUB_OUTPUT

publish:
name: Publish images
runs-on: ubuntu-latest
needs: [collect]

strategy:
fail-fast: false
matrix:
image: ${{ fromJson(needs.collect.outputs.IMAGES) }}
platform:
- linux/amd64
- linux/arm64

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
23 changes: 0 additions & 23 deletions .github/workflows/release.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test
on:
pull_request:
paths:
- 'builds/**/*'
- 'images/**/*'

concurrency:
# Cancel in-progress jobs if a new job is trigged by a commit from the same branch
Expand All @@ -13,9 +13,11 @@ concurrency:

jobs:
test:
name: Test
name: Test the images
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

0 comments on commit 7073f6f

Please sign in to comment.