Skip to content

Commit

Permalink
test pr exists
Browse files Browse the repository at this point in the history
Signed-off-by: Coleen Iona Quadros <[email protected]>
  • Loading branch information
coleenquadros committed Jul 22, 2024
1 parent badd161 commit a4924d0
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 8 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/merge-acm-alertmanager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ACM Alertmanager merger

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-alertmanager.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-alertmanager.yaml'

jobs:
alertmanager-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
with:
upstream: prometheus/alertmanager
downstream: stolostron/prometheus-alertmanager
sandbox: rhobs/acm-prometheus-alertmanager
go-version: "1.22"
restore-upstream: >-
CHANGELOG.md
VERSION
go.mod
go.sum
assets-cmd: |
# Only compress assets if assets actually changed
# The git diff relies on gits remote naming. The merge-flow checks out
# $downstream as origin at the time of writing this code.
if ! git diff --exit-code origin/master ui/react-app; then
make assets-compress
find ui/react-app -type f -name '*.gz' -exec git add {} \;
git add ui/react-app/embed.go
git diff --cached --exit-code || git commit -s -m "[bot] assets: generate"
fi
secrets:
pr-app-id: ${{ secrets.ACM_APP_ID }}
pr-app-private-key: ${{ secrets.ACM_APP_PRIVATE_KEY }}
cloner-app-id: ${{ secrets.ACM_CLONER_APP_ID }}
cloner-app-private-key: ${{ secrets.ACM_CLONER_APP_PRIVATE_KEY }}
slack-webhook-url: ${{ secrets.ACM_SLACK_WEBHOOK_URL }}
31 changes: 25 additions & 6 deletions .github/workflows/merge-acm-flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
uses: rhobs/acm-create-pull-request@push-to-fork-token
id: create-pr
with:
title: "[bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.release }}"
title: "[ACM Obs bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.release }}"
body: |
## Description
This is an automated version bump from CI.
Expand Down Expand Up @@ -245,18 +245,37 @@ jobs:
token: ${{ steps.pr.outputs.token }}
push-to-fork: ${{ inputs.sandbox }}
push-to-fork-token: ${{ steps.cloner.outputs.token }}
- name: Check if PR exists using gh cli
# This step is a hack for the time being as the create-pull-request action has an issue with listing PRs across different named forks of the same repo.
# This is only to get the PR URL if it exists.
if: github.event_name != 'pull_request' && failure()
id: pr-exists
env:
GH_TOKEN: ${{ steps.pr.outputs.token }}
run: |

Check failure on line 255 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/merge-acm-flow.yaml#L255

shellcheck reported issue in this script: SC2236:style:4:10: Use -n instead of ! -z [shellcheck]
Raw output
.github/workflows/merge-acm-flow.yaml:255:9: shellcheck reported issue in this script: SC2236:style:4:10: Use -n instead of ! -z [shellcheck]

Check failure on line 255 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/merge-acm-flow.yaml#L255

shellcheck reported issue in this script: SC2086:info:5:29: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/merge-acm-flow.yaml:255:9: shellcheck reported issue in this script: SC2086:info:5:29: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 255 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/merge-acm-flow.yaml#L255

shellcheck reported issue in this script: SC2086:info:6:32: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/merge-acm-flow.yaml:255:9: shellcheck reported issue in this script: SC2086:info:6:32: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 255 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/merge-acm-flow.yaml#L255

shellcheck reported issue in this script: SC2086:info:9:29: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/merge-acm-flow.yaml:255:9: shellcheck reported issue in this script: SC2086:info:9:29: Double quote to prevent globbing and word splitting [shellcheck]
if [ "${{ steps.create-pr.outcome }}" != "success" ]; then
echo "${{ steps.create-pr.outcome }}"
PR_URL=$(gh pr list --json url --jq '.[0].url' --repo ${{ inputs.downstream }} --state open --head automated-updates-acm-${{ inputs.downstream-branch }})
if [ ! -z "$PR_URL" ]; then
echo "pr_exists=1" >> $GITHUB_OUTPUT
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
echo "PR exists >> $PR_URL"
else
echo "pr_exists=0" >> $GITHUB_OUTPUT
fi
fi
- name: Compose slack message body
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || contains(steps.create_pr.outputs.output, 'A pull request already exists'))
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || steps.pr-exists.outputs.pr_exists == '1' )
continue-on-error: true
id: slack-message
run: |

Check failure on line 271 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/merge-acm-flow.yaml#L271

shellcheck reported issue in this script: SC2086:info:2:149: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/merge-acm-flow.yaml:271:9: shellcheck reported issue in this script: SC2086:info:2:149: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 271 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/merge-acm-flow.yaml#L271

shellcheck reported issue in this script: SC2086:info:4:80: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/merge-acm-flow.yaml:271:9: shellcheck reported issue in this script: SC2086:info:4:80: Double quote to prevent globbing and word splitting [shellcheck]
if [ "${{ steps.create-pr.outputs.pull-request-url }}" == "" ] || [ ${{ steps.fork-sync.outputs.status }} == "uptodate" ] || [ ${{ steps.fork-sync.outputs.status }} == "ahead" ] ; then
if [ ${{ steps.pr-exists.outputs.pr_exists }} != '1' ] || [ ${{ steps.fork-sync.outputs.status }} == "uptodate" ] || [ ${{ steps.fork-sync.outputs.status }} == "ahead" ] ; then
echo "message=${{ inputs.downstream }} is already ${{ steps.fork-sync.outputs.status }} with tag ${{ steps.org.outputs.downstream-version }}." >> $GITHUB_OUTPUT
else
echo "message=PR ${{ steps.create-pr.outputs.pull-request-url }} has been ${{ steps.create-pr.outputs.pull-request-operation || 'updated' }}." >> $GITHUB_OUTPUT
echo "message=PR ${{ steps.pr-exists.outputs.pr_url }} has been updated." >> $GITHUB_OUTPUT
fi
- uses: 8398a7/action-slack@v3
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || contains(steps.create_pr.outputs.output, 'A pull request already exists'))
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || steps.pr-exists.outputs.pr_exists == '1')
continue-on-error: true
with:
status: custom
Expand All @@ -271,7 +290,7 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }}
- uses: 8398a7/action-slack@v3
if: github.event_name != 'pull_request' && (failure() && steps.fork-sync.outputs.status != 'uptodate' && steps.fork-sync.outputs.status != 'ahead' && !contains(steps.create_pr.outputs.output, 'A pull request already exists'))
if: github.event_name != 'pull_request' && (failure() && steps.fork-sync.outputs.status != 'uptodate' && steps.fork-sync.outputs.status != 'ahead' && !(steps.pr-exists.outputs.pr_exists == '1'))
continue-on-error: true
with:
status: custom
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-acm-prometheus-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ACM Prometheus Operator merger
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' #@daily
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-acm-prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ACM Prometheus merger
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' #@daily
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
Expand Down

0 comments on commit a4924d0

Please sign in to comment.