Closed shaggyyy2002 closed 4 months ago
using this under the release.yml file so that dispatch runs when the release.yml file is build as mentioned needs: build
. if created a separate file for this it may sometimes run first or last as its picked or we would need to use if else statements, this is more easy.
name: Release
on:
push:
tags:
- 'v*.*.*'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GHR_VERSION: 0.12.0
IMAGE_NAME: index.docker.io/metacall/core
IMAGE_REGISTRY: index.docker.io
ARTIFACTS_PATH: ./build-artifacts
# GITHUB_TOKEN - From default secrets
# GITHUB_REPOSITORY - Default variable
jobs:
build:
name: Build the core
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
.
.
.
. [continued in core]
.
.
dispatch:
needs: build
strategy:
matrix:
repo: ['company/repo1', 'company/repo2', 'company/repo3']
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: ${{ matrix.repo }}
event-type: test-trigger
This is what it would look like:
We are not using release.yml file that often so 2 possible solution left.
yml
file name: CI Signal to other dist repos
on:
push:
tags:
- 'v*'
jobs:
check_completion:
runs-on: ubuntu-latest
outputs:
{other OS}
windows_success: ${{ steps.windows.outputs.success }}
> {Other OS checks}
- name: Check Windows Test Completion
id: windows
if: github.event.workflow_run.name == 'Windows Test'
run: |
echo "::set-output name=success::${{ github.event.workflow_run.conclusion == 'success' }}"
dispatch_windows:
if: ${{ steps.check_completion.outputs.windows_success == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Windows Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: shaggyyy2002/distributable-windows
event-type: test-trigger
trigger_dist_windows:
needs: windows-test
if: ${{ success() }}
runs-on: ubuntu-latest
steps:
- name: Windows Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: metacall/distributable-windows
event-type: test-trigger
ref: ${{ github.ref }}
To solve the issue, I am using the 2 one so that no need to write extra code and logic. The first one (creating a separate file) would've required us to write something to make sure our dist repo triggers when all the checks and tests are passed. So choosing the 2nd option
---
✅ Our commit & tag when pushed it did trigger the dist repo.
❌ The error facing right now is in the dist repo to release it, it needs a git tag, which is being passed from the core repo but its not accessible from the dist repos.
some minor changes: we are using client-payload: '{"ref": "${{ github.ref }}"}'
the earlier ref: ${{ github.ref }}
is deprecated for v3 dispatch.
More info : https://github.com/peter-evans/repository-dispatch
On the core repo its done.
changes needed on the dist repo's
name: "MetaCall Distributable Release"
on:
repository_dispatch:
types: [test-trigger]
(Image from linux-dist repo)
🚀 Feature
Consistent CI across multiple repositories in order to provide continuous delivery of MetaCall binaries with report of errors for when some distributable fails on a version of MetaCall Core.
Is your feature request related to a problem?
Earlier when a new tag was being pushed it would only trigger the core repo CI to build binaries. Adding a new CI in which when a new tag is pushed and repo is built successfully then it will trigger the distributable repo's (windows/linux/macos) to build new binaries with newer version/tags.
Describe the solution you'd like
My current solution uses github.com/peter-evans/repository-dispatch@v2. Where we can use this Github Action to trigger in remote repo
Dispatch to multiple repositories. You can dispatch to multiple repositories by using a matrix strategy. In the following example, after the build job succeeds, an event is dispatched to three different repositories.