.github: clean up logic in docker build workflow to cleanly separate … #234
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
# This workflow is an example of a combination of automatic and manual release. | |
# The triggers are: | |
# - Push | |
# - Workflow Dispatch | |
# | |
# This workflow uses the `if` conditions to control when the CI runs versus when | |
# a release is also created. | |
# | |
# The CI runs when pull requests are created and also when code is merged into | |
# main, i.e. push events to main. | |
# | |
# Lastly, it will trigger from manually workflow dispatches. | |
name: CI and Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
# Inputs the workflow accepts. | |
inputs: | |
version: | |
# Friendly description to be shown in the UI instead of 'name' | |
description: "Semver type of new version (major / minor / patch)" | |
# Input has to be provided for the workflow to run | |
required: true | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
# Example for docker file linting | |
# hadolint: | |
# uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@master | |
yamllint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/yamllint | |
markdown-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/markdown-lint | |
# Make a release if | |
# - there were changes and this is a scheduled job | |
# - This is a manually trigger job, i.e. workflow_dispatch | |
release: | |
needs: [yamllint, markdown-lint] | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
permissions: "write-all" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Version Release | |
uses: ./.github/actions/version-release | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
version-bump: ${{inputs.version}} | |
# Example for docker builds | |
# docker: | |
# needs: release | |
# name: Build and Push Docker image to Docker Hub | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Check out the repo | |
# uses: actions/checkout@v4 | |
# - uses: celestiaorg/.github/.github/actions/docker-publish@master | |
# with: | |
# docker_username: ${{ secrets.DOCKER_USERNAME}} | |
# docker_password: ${{ secrets.DOCKER_PASSWORD}} | |
# docker_repository: <update> | |
# semver_version: ${{ needs.release.outputs.new_version }} | |
# notify-slack-on-failure will send a message to slack if the workflow fails. | |
# This shows how to use the reusable workflow. Below is how to call it directly. | |
notify-slack-on-failure: | |
needs: [yamllint, markdown-lint] | |
# Always run, regardless of job failures, only run on main/master branches. | |
if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') | |
secrets: inherit | |
uses: ./.github/workflows/reusable_notify_slack.yml | |
# Option for directly calling the workflow | |
# notify-slack-on-failure: | |
# needs: [yamllint, markdown-lint] | |
# if: always() | |
# # if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') | |
# runs-on: ubuntu-latest | |
# steps: | |
# # run this action to get the workflow conclusion | |
# # You can get the conclusion via env (env.WORKFLOW_CONCLUSION) | |
# - uses: technote-space/workflow-conclusion-action@v3 | |
# - name: Notify Slack On Failure | |
# uses: ravsamhq/notify-slack-action@v2 | |
# with: | |
# status: ${{ env.WORKFLOW_CONCLUSION }} | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# notification_title: "{workflow} has {status_message}" | |
# message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>" | |
# footer: "" | |
# notify_when: "failure" | |
# env: | |
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_RELEASE_CHANNEL }} |