Skip to content

Commit

Permalink
chore(ci): add condition for "auto-releasing"
Browse files Browse the repository at this point in the history
Signed-off-by: John Cowen <[email protected]>
  • Loading branch information
johncowen committed Oct 9, 2024
1 parent d3a8553 commit 5b34c3b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ concurrency:
on:
push:
branches: [master, 'release-[0-9]+.[0-9]+']
pull_request:
branches: [master, 'release-[0-9]+.[0-9]+']
# pull_request:
# branches: [master, 'release-[0-9]+.[0-9]+']
schedule:
- cron: '31 11 * * 4'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ concurrency:
on:
push:
branches: [master, 'release-[0-9]+.[0-9]+']
pull_request:
types: [opened, reopened, synchronize]
# pull_request:
# types: [opened, reopened, synchronize]

permissions:
contents: read # for checking out the repository (e.g. actions/checkout)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
name: 'Create GUI update PR'
run-name: 'Create GUI update PR (branch: ${{ github.event.workflow_run.head_branch || inputs.branch }})'

# **Note 1**: You can merge a pull request into a release branch of the form “release-$MAJOR.$MINOR” (e.g. “release-2.1”) in order to create the GUI update PR in the matching release branch of the host repository. For this to work, the name of this repository’s release branch must match that of the host repository exactly.
# **Note 2**: Since this workflow can be triggered using the `workflow_run` event type, one needs to pay special attention to the context in which runs will be executed based on this workflow. Most importantly, runs will be using the workflow file found **in the project’s default branch**. This means that context variables like `github.ref` and `github.ref_name` will refer to the default branch **and not the branch that caused the workflow_run event to trigger**. Also, it likely means that to change the behavior of the workflow in a release branch, one will actually have to update the workflow file in the default branch, too.
name: 'Build and release to kumahq/kuma'
run-name: 'Build and release to kumahq/kuma (branch: ${{ github.event.workflow_run.head_branch || inputs.branch }})'

# **Note 1**: You can merge a pull request into a release branch of the form
# “release-$MAJOR.$MINOR” (e.g. “release-2.1”) in order to create the GUI
# update PR in the matching release branch of the host repository. For this to
# work, the name of this repository’s release branch must match that of the
# host repository exactly.

# **Note 2**: Since this workflow can be triggered using the `workflow_run`
# event type, one needs to pay special attention to the context in which runs
# will be executed based on this workflow. Most importantly, runs will be using
# the workflow file found **in the project’s default branch**. This means that
# context variables like `github.ref` and `github.ref_name` will refer to the
# default branch **and not the branch that caused the workflow_run event to
# trigger**. Also, it likely means that to change the behavior of the workflow
# in a release branch, one will actually have to update the workflow file in
# the default branch, too.

on:
# Allows running the workflow manually.
Expand All @@ -19,8 +32,13 @@ on:
workflow_run:
workflows: ['Tests']
types: [completed]
# See “Filter pattern cheat sheet” https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
branches: [master, 'release-[0-9]+.[0-9]+']
# See “Filter pattern cheat sheet”
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
branches:
- master
- release-[0-9]+.[0-9]+
pull_request:
types: [opened, reopened, synchronize]

permissions:
contents: read # for checking out the repository (e.g. actions/checkout)
Expand All @@ -32,12 +50,38 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || inputs.branch }}

jobs:
repository:
runs-on: ubuntu-latest
outputs:
token: ${{ steps.topics.outputs.token }}
topics: ${{ steps.topics.outputs.topics }}
steps:
- id: token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- id: topics
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
run: |
echo "topics=$(\
gh repo view kumahq/kuma-gui \
--json repositoryTopics \
--jq '.repositoryTopics | map(.name) | join(",")'\
)" >> $GITHUB_OUTPUT
##
# Creates a pull request in the main application to update its GUI.
create-gui-pr:
timeout-minutes: 10
# Only runs this job when the triggering workflow run was a success (i.e. the “Tests” workflow passes).
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
name: Create GUI update PR
needs:
- repository
if: ${{ contains(needs.repository.outputs.topics, 'auto-release') &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
)
}}
timeout-minutes: 10
runs-on: ubuntu-latest
env:
SHA: ${{ github.event.workflow_run.head_sha || inputs.sha }}
Expand Down

0 comments on commit 5b34c3b

Please sign in to comment.