Changed conditions of running GitHub actions (#2082)

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 <george.gcac@gmail.com>
This commit is contained in:
George 2024-01-19 11:11:18 -03:00 committed by GitHub
parent 1d4a8c742b
commit 04f7b041a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 109 additions and 54 deletions

View File

@ -28,14 +28,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Ruby - name: Setup Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: "3.2.2" ruby-version: "3.3"
bundler-cache: true bundler-cache: true
- name: Update _config.yml ⚙️ - name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@v0.13.1 uses: fjogeleit/yaml-update-action@main
with: with:
commitChange: false commitChange: false
valueFile: "_config.yml" valueFile: "_config.yml"
@ -48,9 +48,11 @@ jobs:
run: | run: |
pip3 install --upgrade jupyter pip3 install --upgrade jupyter
npm install -g mermaid.cli npm install -g mermaid.cli
npm install -g purgecss
export JEKYLL_ENV=production export JEKYLL_ENV=production
bundle exec jekyll build --lsi bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js purgecss -c purgecss.config.js
- name: Run axe 🪓 - name: Run axe 🪓
# https://github.com/dequelabs/axe-core-npm/tree/develop/packages/cli # https://github.com/dequelabs/axe-core-npm/tree/develop/packages/cli

View File

@ -1,33 +1,29 @@
name: Check for broken links on site name: Check for broken links on site
on: on:
push: workflow_run:
branches: workflows: [Deploy site]
- master types: [completed]
- main
pull_request:
branches:
- master
- main
workflow_dispatch:
permissions: permissions:
contents: write contents: write
jobs: 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 # available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Ruby - name: Setup Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: "3.2.2" ruby-version: "3.3"
bundler-cache: true bundler-cache: true
- name: Update _config.yml ⚙️ - name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@v0.13.1 uses: fjogeleit/yaml-update-action@main
with: with:
commitChange: false commitChange: false
valueFile: "_config.yml" valueFile: "_config.yml"
@ -40,9 +36,11 @@ jobs:
run: | run: |
pip3 install --upgrade jupyter pip3 install --upgrade jupyter
npm install -g mermaid.cli npm install -g mermaid.cli
npm install -g purgecss
export JEKYLL_ENV=production export JEKYLL_ENV=production
bundle exec jekyll build --lsi bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js purgecss -c purgecss.config.js
- name: Link Checker 🔗 - name: Link Checker 🔗
uses: lycheeverse/lychee-action@v1.9.0 uses: lycheeverse/lychee-action@v1.9.0

View File

@ -2,13 +2,43 @@ name: Check for broken links
on: on:
push: 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: 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: jobs:
link-checker: link-checker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Link Checker 🔗 - name: Link Checker 🔗
uses: lycheeverse/lychee-action@v1.9.0 uses: lycheeverse/lychee-action@v1.9.0

View File

@ -4,6 +4,13 @@ on:
push: push:
tags: tags:
- "v*" - "v*"
paths:
- "bin/entry_point.sh"
- "Dockerfile"
- "Gemfile"
- "Gemfile.lock"
- "package.json"
- "package-lock.json"
jobs: jobs:
build: build:
@ -11,28 +18,28 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
- name: Buildx - name: Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: amirpourmand/al-folio images: amirpourmand/al-folio
- name: Login - name: Login
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8

View File

@ -2,7 +2,16 @@ name: Docker Image CI
on: on:
push: push:
branches: [master] branches:
- master
- main
paths:
- "bin/entry_point.sh"
- "Dockerfile"
- "Gemfile"
- "Gemfile.lock"
- "package.json"
- "package-lock.json"
jobs: jobs:
build: build:
@ -11,22 +20,22 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
- name: Buildx - name: Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Login - name: Login
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v4 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: true push: true

View File

@ -1,14 +1,9 @@
name: Deploy site name: Deploy site
on: on:
push: workflow_run:
branches: workflows: [Check for broken links]
- master types: [completed]
- main
pull_request:
branches:
- master
- main
workflow_dispatch: workflow_dispatch:
permissions: permissions:
@ -16,18 +11,20 @@ permissions:
jobs: jobs:
deploy: 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 # available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Ruby - name: Setup Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: "3.2.2" ruby-version: "3.3"
bundler-cache: true bundler-cache: true
- name: Update _config.yml ⚙️ - name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@v0.13.1 uses: fjogeleit/yaml-update-action@main
with: with:
commitChange: false commitChange: false
valueFile: "_config.yml" valueFile: "_config.yml"
@ -37,9 +34,11 @@ jobs:
run: | run: |
pip3 install --upgrade jupyter pip3 install --upgrade jupyter
npm install -g mermaid.cli npm install -g mermaid.cli
npm install -g purgecss
export JEKYLL_ENV=production export JEKYLL_ENV=production
bundle exec jekyll build --lsi bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js purgecss -c purgecss.config.js
- name: Deploy 🚀 - name: Deploy 🚀
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'

View File

@ -14,19 +14,19 @@ on:
jobs: jobs:
build: 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 runs-on: ubuntu-latest
if: github.repository_owner == 'alshedivat'
defaults: defaults:
run: run:
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Login - name: Login
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
@ -34,7 +34,7 @@ jobs:
- name: update docker-compose - name: update docker-compose
shell: bash shell: bash
run: | 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 cat ${{ github.workspace }}/docker-compose.yml
- uses: kitabisa/docker-slim-action@v1.0.3 - uses: kitabisa/docker-slim-action@v1.0.3

View File

@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Node.js ⚙️ - name: Setup Node.js ⚙️
uses: actions/setup-node@v4 uses: actions/setup-node@v4
- name: Install Prettier 💾 - name: Install Prettier 💾

View File

@ -181,9 +181,9 @@ jobs:
steps: steps:
# To use this repository's private action, you must check out the repository # To use this repository's private action, you must check out the repository
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: actions-template-sync - name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.7.3 uses: AndreasAugustin/actions-template-sync@v1
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: alshedivat/al-folio source_repo_path: alshedivat/al-folio

View File

@ -206,13 +206,23 @@ kramdown:
include: ["_pages"] include: ["_pages"]
exclude: exclude:
- bin - bin
- CONTRIBUTING.md
- CUSTOMIZE.md
- docker-compose.yml
- Dockerfile
- FAQ.md
- Gemfile - Gemfile
- Gemfile.lock - Gemfile.lock
- INSTALL.md
- LICENSE
- package.json
- package-lock.json
- purgecss.config.js
- README.md
- vendor - vendor
keep_files: keep_files:
- CNAME - CNAME
- .nojekyll - .nojekyll
- .git
# Plug-ins # Plug-ins
plugins: plugins:

View File

@ -1,6 +1,6 @@
module.exports = { module.exports = {
content: ["_site/**/*.html", "_site/**/*.js"], content: ["_site/**.html", "_site/**.js"],
css: ["_site/assets/css/*.css"], css: ["_site/assets/css/*.css"],
output: "_site/assets/css/", output: "_site/assets/css/",
skippedContentGlobs: ["_site/assets/**/*.html"], skippedContentGlobs: ["_site/assets/**.html"],
}; };