Skip to content

Commit

Permalink
Changed conditions of running GitHub actions (alshedivat#2082)
Browse files Browse the repository at this point in the history
The GitHub actions were running everytime a new commit was made to the
repo, but that wasn't needed. For example, we don't need to try to
create a new docker image if the libraries didn't change, same to build
the whole site after a change in the README.md.

---------

Signed-off-by: George Araújo <[email protected]>
  • Loading branch information
george-gca authored Jan 19, 2024
1 parent eb13238 commit 3271fb3
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 54 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/axe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.2"
ruby-version: "3.3"
bundler-cache: true
- name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@v0.13.1
uses: fjogeleit/yaml-update-action@main
with:
commitChange: false
valueFile: "_config.yml"
Expand All @@ -48,9 +48,11 @@ jobs:
run: |
pip3 install --upgrade jupyter
npm install -g mermaid.cli
npm install -g purgecss
export JEKYLL_ENV=production
bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js
- name: Run axe 🪓
# https://github.com/dequelabs/axe-core-npm/tree/develop/packages/cli
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/broken-links-site.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
name: Check for broken links on site

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
workflow_dispatch:
workflow_run:
workflows: [Deploy site]
types: [completed]

permissions:
contents: write

jobs:
deploy:
check-links-on-site:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }}
# available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.2"
ruby-version: "3.3"
bundler-cache: true
- name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@v0.13.1
uses: fjogeleit/yaml-update-action@main
with:
commitChange: false
valueFile: "_config.yml"
Expand All @@ -40,9 +36,11 @@ jobs:
run: |
pip3 install --upgrade jupyter
npm install -g mermaid.cli
npm install -g purgecss
export JEKYLL_ENV=production
bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js
- name: Link Checker 🔗
uses: lycheeverse/[email protected]
Expand Down
32 changes: 31 additions & 1 deletion .github/workflows/broken-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,43 @@ name: Check for broken links

on:
push:
branches:
- master
- main
paths:
- "assets/**"
- "**.html"
- "**.js"
- "**.liquid"
- "**/*.md"
- "**.yml"
- "!.github/workflows/axe.yml"
- "!.github/workflows/deploy-docker-tag.yml"
- "!.github/workflows/deploy-image.yml"
- "!.github/workflows/docker-slim.yml"
- "!.github/workflows/prettier.yml"
pull_request:
branches:
- master
- main
paths:
- "assets/**"
- "**.html"
- "**.js"
- "**.liquid"
- "**/*.md"
- "**.yml"
- "!.github/workflows/axe.yml"
- "!.github/workflows/deploy-docker-tag.yml"
- "!.github/workflows/deploy-image.yml"
- "!.github/workflows/docker-slim.yml"
- "!.github/workflows/prettier.yml"

jobs:
link-checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Link Checker 🔗
uses: lycheeverse/[email protected]
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/deploy-docker-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,42 @@ on:
push:
tags:
- "v*"
paths:
- "bin/entry_point.sh"
- "Dockerfile"
- "Gemfile"
- "Gemfile.lock"
- "package.json"
- "package-lock.json"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: amirpourmand/al-folio

- name: Login
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64/v8
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ name: Docker Image CI

on:
push:
branches: [master]
branches:
- master
- main
paths:
- "bin/entry_point.sh"
- "Dockerfile"
- "Gemfile"
- "Gemfile.lock"
- "package.json"
- "package-lock.json"

jobs:
build:
Expand All @@ -11,22 +20,22 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
name: Deploy site

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
workflow_run:
workflows: [Check for broken links]
types: [completed]
workflow_dispatch:

permissions:
contents: write

jobs:
deploy:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
# available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.2"
ruby-version: "3.3"
bundler-cache: true
- name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@v0.13.1
uses: fjogeleit/yaml-update-action@main
with:
commitChange: false
valueFile: "_config.yml"
Expand All @@ -37,9 +34,11 @@ jobs:
run: |
pip3 install --upgrade jupyter
npm install -g mermaid.cli
npm install -g purgecss
export JEKYLL_ENV=production
bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js
- name: Deploy 🚀
if: github.event_name != 'pull_request'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker-slim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ on:

jobs:
build:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }} and github.repository_owner == 'alshedivat'
runs-on: ubuntu-latest
if: github.repository_owner == 'alshedivat'

defaults:
run:
working-directory: ${{ github.workspace }}

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: update docker-compose
shell: bash
run: |
sed -i "s|\.:|${{ github.workspace }}:|g" ${{ github.workspace }}/docker-compose.yml
sed -i "s|\.:|${{ github.workspace }}:|g" ${{ github.workspace }}/docker-compose.yml
cat ${{ github.workspace }}/docker-compose.yml
- uses: kitabisa/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Node.js ⚙️
uses: actions/setup-node@v4
- name: Install Prettier 💾
Expand Down
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ jobs:
steps:
# To use this repository's private action, you must check out the repository
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.7.3
uses: AndreasAugustin/actions-template-sync@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: alshedivat/al-folio
Expand Down
12 changes: 11 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,23 @@ kramdown:
include: ["_pages"]
exclude:
- bin
- CONTRIBUTING.md
- CUSTOMIZE.md
- docker-compose.yml
- Dockerfile
- FAQ.md
- Gemfile
- Gemfile.lock
- INSTALL.md
- LICENSE
- package.json
- package-lock.json
- purgecss.config.js
- README.md
- vendor
keep_files:
- CNAME
- .nojekyll
- .git

# Plug-ins
plugins:
Expand Down
4 changes: 2 additions & 2 deletions purgecss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
content: ["_site/**/*.html", "_site/**/*.js"],
content: ["_site/**.html", "_site/**.js"],
css: ["_site/assets/css/*.css"],
output: "_site/assets/css/",
skippedContentGlobs: ["_site/assets/**/*.html"],
skippedContentGlobs: ["_site/assets/**.html"],
};

0 comments on commit 3271fb3

Please sign in to comment.