ci: publish container and artifacts on merge to main (#12) #117
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: CI/CD | |
on: | |
workflow_call: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
# https://stackoverflow.com/a/72408109 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check-inputs: | |
runs-on: ubuntu-24.04 | |
outputs: | |
cargo-profile: ${{ steps.set-cargo-profile.outputs.CI_CARGO_PROFILE }} | |
is-default-branch: ${{ steps.set-is-default-branch.outputs.CI_IS_DEFAULT_BRANCH }} | |
steps: | |
- name: Set is-default-branch | |
id: set-is-default-branch | |
run: | | |
CI_IS_DEFAULT_BRANCH="${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}" | |
echo "CI_IS_DEFAULT_BRANCH=${CI_IS_DEFAULT_BRANCH}" >> $GITHUB_OUTPUT | |
echo "CI_IS_DEFAULT_BRANCH=${CI_IS_DEFAULT_BRANCH}" >> $GITHUB_ENV | |
echo "CI_IS_DEFAULT_BRANCH=${CI_IS_DEFAULT_BRANCH}" | |
- name: Set cargo-profile | |
id: set-cargo-profile | |
run: | | |
if [[ ${CI_IS_DEFAULT_BRANCH} == 'true' ]]; then | |
CI_CARGO_PROFILE="artifact" | |
else | |
CI_CARGO_PROFILE="artifact-dev" | |
fi | |
echo "CI_CARGO_PROFILE=${CI_CARGO_PROFILE}" >> $GITHUB_OUTPUT | |
echo "CI_CARGO_PROFILE=${CI_CARGO_PROFILE}" | |
rust: | |
name: Rust | |
needs: check-inputs | |
uses: ./.github/workflows/rust.yaml | |
with: | |
cargo-profile: ${{ needs.check-inputs.outputs.cargo-profile }} | |
container: | |
name: Container | |
needs: [rust, check-inputs] | |
uses: ./.github/workflows/container.yaml | |
with: | |
push: ${{ needs.check-inputs.outputs.is-default-branch == 'true' }} | |
additional-tags: ${{ (needs.check-inputs.outputs.is-default-branch == 'true') && 'latest' || '' }} | |