Skip to content

Commit

Permalink
feat: replace issue creation with slack alert (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
leiicamundi authored Jun 6, 2024
1 parent 34eef55 commit d82dae9
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 32 deletions.
4 changes: 4 additions & 0 deletions .github/actions/rosa-create-cluster/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ runs:
shell: bash
retry_wait_seconds: 15
command: |
: # see https://github.com/nick-fields/retry/issues/133
set -o errexit
set -o pipefail
oc login --username "${{ inputs.admin-username }}" --password "${{ inputs.admin-password }}" "${{ steps.cluster_info.outputs.cluster_api }}"
rosa grant user cluster-admin --cluster="${{ inputs.cluster-name }}" --user="${{ inputs.admin-username }}" --region="${{ inputs.aws-region }}"
Expand Down
5 changes: 0 additions & 5 deletions .github/templates/issue_delete_clusters_failed.md

This file was deleted.

33 changes: 7 additions & 26 deletions .github/workflows/daily-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ env:
TESTS_AWS_REGION: "eu-west-2"
TF_S3_BUCKET: "camunda-tf-rosa"

ASSIGNEES_ISSUE_ERROR: "Langleu, leiicamundi"

jobs:

cleanup-clusters:
Expand Down Expand Up @@ -76,28 +74,11 @@ jobs:
tf-bucket: "${{ env.TF_S3_BUCKET }}"
max-age-hours-cluster: "${{ env.MAX_AGE_HOURS_CLUSTER }}"

- name: Close issue in case of success
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
issue_url=$(gh --repo "${{ github.repository }}" search issues "Failed to cleanup clusters" --state=open --label="schedule" --json 'url' | jq '.[0].url' -r)
if [ "$issue_url" != "null" ]; then
gh issue close --comment "Auto-closing issue as the cleanup has been successfuly ran in ${{ env.WORKFLOW_URL }}." "$issue_url"
else
echo "No open issues found with the specified criteria."
fi
- name: Create issue on failure
if: failure()
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Notify in Slack in case of failure
id: slack-notification
if: failure() && github.event_name == 'schedule'
uses: camunda/infraex-common-config/.github/actions/report-failure-on-slack@705df1af7d06626b8c6838f58123bb3bf84fc093 # main
with:
assignees: "${{ env.ASSIGNEES_ISSUE_ERROR }}"
update_existing: true
search_existing: open
filename: .github/templates/issue_delete_clusters_failed.md
vault_addr: ${{ secrets.VAULT_ADDR }}
vault_role_id: ${{ secrets.VAULT_ROLE_ID }}
vault_secret_id: ${{ secrets.VAULT_SECRET_ID }}
13 changes: 13 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
pull_request_target:
schedule:
- cron: "0 1 * * 1"
pull_request:
paths:
- .github/workflows/labeler.yml

jobs:
labeler:
permissions:
Expand All @@ -11,3 +15,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5

- name: Notify in Slack in case of failure
id: slack-notification
if: failure() && github.event_name == 'schedule'
uses: camunda/infraex-common-config/.github/actions/report-failure-on-slack@705df1af7d06626b8c6838f58123bb3bf84fc093 # main
with:
vault_addr: ${{ secrets.VAULT_ADDR }}
vault_role_id: ${{ secrets.VAULT_ROLE_ID }}
vault_secret_id: ${{ secrets.VAULT_SECRET_ID }}
14 changes: 13 additions & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
workflow_dispatch:
schedule:
- cron: "0 3 1 * *"
pull_request:
paths:
- .github/workflows/links.yml

jobs:
lint:
Expand Down Expand Up @@ -32,9 +35,18 @@ jobs:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Create Issue From File
if: ${{ github.event_name == 'schedule' && env.lychee_exit_code != 0 }}
if: failure() && github.event_name == 'schedule'
uses: peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f # v4
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue

- name: Notify in Slack in case of failure
id: slack-notification
if: failure() && github.event_name == 'schedule'
uses: camunda/infraex-common-config/.github/actions/report-failure-on-slack@705df1af7d06626b8c6838f58123bb3bf84fc093 # main
with:
vault_addr: ${{ secrets.VAULT_ADDR }}
vault_role_id: ${{ secrets.VAULT_ROLE_ID }}
vault_secret_id: ${{ secrets.VAULT_SECRET_ID }}
9 changes: 9 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,12 @@ jobs:
cluster-name: "${{ steps.commit_info.outputs.cluster_name }}"
aws-region: ${{ env.TESTS_AWS_REGION }}
s3-backend-bucket: ${{ env.TF_S3_BUCKET }}

- name: Notify in Slack in case of failure
id: slack-notification
if: failure() && github.event_name == 'schedule'
uses: camunda/infraex-common-config/.github/actions/report-failure-on-slack@705df1af7d06626b8c6838f58123bb3bf84fc093 # main
with:
vault_addr: ${{ secrets.VAULT_ADDR }}
vault_role_id: ${{ secrets.VAULT_ROLE_ID }}
vault_secret_id: ${{ secrets.VAULT_SECRET_ID }}

0 comments on commit d82dae9

Please sign in to comment.