Skip to content

feat: build when release branch is created and make mq a dispatch workflow #18515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 25, 2025
7 changes: 6 additions & 1 deletion .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: 'Prep Dependencies'
on:
workflow_call:
inputs:
force_all_to_be_affected:
description: 'Should all be affected'
required: false
type: boolean
default: false
main_branch:
default: 'main'
type: string
Expand Down Expand Up @@ -46,7 +51,7 @@ on:
env:
COMPOSE_HTTP_TIMEOUT: 180
SKIP_GENERATED_CACHE: ${{ contains(github.event.pull_request.labels.*.name, 'skip-generated-cache') }}
NX_AFFECTED_ALL: ${{ contains(github.event.pull_request.labels.*.name, 'nx-affected-all') }}
NX_AFFECTED_ALL: ${{ inputs.force_all_to_be_affected || contains(github.event.pull_request.labels.*.name, 'nx-affected-all') }}
DISABLE_CHUNKS: 'true'
DISABLE_GROUPING: 'false'
DISABLE_PROBLEMATIC: 'false'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/merge-queue.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Validate code in the merge queue (post merge)

on:
workflow_dispatch: {}
merge_group:

defaults:
Expand Down Expand Up @@ -48,7 +49,8 @@ jobs:
secrets: inherit
with:
run_merge_queue: true
main_branch: ${{ github.event.merge_group.base_ref }}
force_all_to_be_affected: ${{ github.event_name == 'workflow_dispatch' }}
main_branch: ${{ github.event.merge_group.base_ref || github.ref_name }}
needs:
- pre-checks
docker-build:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/on-release-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release created


on:
push:
branches:
- 'releases/**'
jobs:
mq:
if: github.event.created
runs-on: arc-runners
steps:
- run: |
export GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF/refs\/heads\//}}"
echo "New release branch created: $GIT_BRANCH"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/merge-queue.yml/dispatches \
-d "{\"ref\":\"$GIT_BRANCH\"}"


19 changes: 16 additions & 3 deletions scripts/ci/docker/generate-tag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ console.info(`Git SHA: ${sha}`)
console.info(`Helm values branch: ${typeOfDeployment.dev ? 'main' : 'release'}`)

function shouldRun() {
if (eventName === 'merge_group') {
if (eventName === 'merge_group' || eventName === 'workflow_dispatch') {
if (MAIN_BRANCHES.includes(targetBranch)) {
return true;
}
Expand All @@ -47,7 +47,7 @@ function getTagname() {
throw new Error(`Unsupported event: ${eventName}`)
// return `pr-${context.payload.pull_request.number}-${randomTag}`;
}
if (eventName === 'merge_group') {
if (eventName === 'merge_group' || eventName === 'workflow_dispatch') {
const dateString = new Date().toISOString().split('T')[0].replace(/-/g, '')
if (typeOfDeployment.dev) {
return `dev_${dateString}_${randomTag}`
Expand Down Expand Up @@ -78,6 +78,16 @@ function getArtifactname() {
throw new Error(`Unable to determine artifact name for merge_group event`)
}

if (eventName === 'workflow_dispatch') {
if (typeOfDeployment.dev) {
return `main-${context.sha}`
}
if (typeOfDeployment.prod) {
return `release-${context.sha}`
}
throw new Error(`Unable to determine artifact name for merge_group event`)
}

throw new Error(
`Unable to determine artifact name for event type: ${eventName}`,
)
Expand All @@ -103,11 +113,14 @@ function getTypeOfDeployment() {

function getTargetBranch() {
if (eventName === 'pull_request' && context.payload?.pull_request?.base.ref) {
return context.payload.pull_request.base.ref
return context.payload.pull_request.base.ref.replace('refs/heads/', '')
}
if (eventName === 'merge_group') {
return context.payload.merge_group.base_ref.replace('refs/heads/', '')
}
if (eventName === 'workflow_dispatch') {
return context.ref.replace('refs/heads/', '')
}

throw new Error(
`Unable to determine target branch for event type: ${eventName}`,
Expand Down
3 changes: 3 additions & 0 deletions scripts/ci/docker/get-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ function getBranch() {
if (context.eventName === 'merge_group') {
return context.payload.merge_group.base_ref.replace('refs/heads/', '')
}
if (context.eventName === 'workflow_dispatch') {
return context.ref.replace('refs/heads/', '');
}
throw new Error(`Unsupported event: ${context.eventName}`)
}

Expand Down
Loading