fix(ci): Enable edge tag to prevent failing CD on main #261
Workflow file for this run
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: Build, Test, and Release | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' # For v1.0, v0.1.0, etc | |
pull_request: | |
branches: | |
- 'main' | |
workflow_dispatch: | |
concurrency: | |
# Allow concurrent run for main, MR, and tag | |
# Disallow concurrent runs on same MRs, tags, and main (triggered by dispatch, schedule, or push) | |
group: ${{ format('{0}-{1}', github.job, github.ref) }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.2' | |
bundler-cache: true | |
- name: lint with rubocop | |
run: bundle exec rubocop | |
test: | |
needs: | |
- lint | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, windows-latest ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.2' | |
bundler-cache: true | |
- name: test with rspec | |
run: bundle exec rspec | |
release: | |
needs: | |
- lint | |
- test | |
runs-on: ubuntu-latest | |
if: github.ref_type == 'tag' | |
steps: | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
generate_release_notes: true | |
name: ${{ format('Release {0}', github.ref_name) }} | |
prerelease: ${{ contains(github.ref_name, '-rc-') }} | |
draft: true | |
docker: | |
needs: | |
- lint | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
leviem1/jpig | |
tags: | | |
type=edge,branch=main | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
notify: | |
name: Send job complete notification | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- test | |
- release | |
- docker | |
if: always() && (github.ref_type == 'tag' || github.ref_name == 'main') | |
steps: | |
- name: Notify on success | |
if: needs.lint.result == 'success' && needs.test.result == 'success' && needs.release.result == 'success' && needs.docker.result == 'success' | |
uses: appleboy/discord-action@v1.0.0 | |
with: | |
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} | |
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} | |
color: "#800000" | |
username: "jekyll-post-image-generator Release Bot" | |
message: > | |
An jekyll-post-image-generator release was deployed: | |
https://github.com/sebs-scholarship/jekyll-post-image-generator/releases/tag/${{ github.ref_name }} | |
- name: Notify on failure | |
if: needs.lint.result == 'failure' || needs.test.result == 'failure' || needs.release.result == 'failure' || needs.docker.result == 'failure' | |
uses: appleboy/discord-action@v1.0.0 | |
with: | |
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} | |
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} | |
color: "#800000" | |
username: "jekyll-post-image-generator Release Bot" | |
message: > | |
An jekyll-post-image-generator build failed: | |
https://github.com/sebs-scholarship/jekyll-post-image-generator/actions/runs/${{ github.run_id }} |