From 7fef7b07f4d3c4652d465c48d6a184d4715cfe8e Mon Sep 17 00:00:00 2001 From: Oscar Wieman Date: Mon, 7 Aug 2023 15:13:07 +0200 Subject: [PATCH] [skip ci] Deploy from chat and let argocd update status --- .github/workflows/issue-ops.yaml | 34 ++++++++++++ .github/workflows/workflow-dispatch.yaml | 17 ++++++ charts/drinkn/templates/github-webhooks.yaml | 57 ++++++++++++++++++++ charts/drinkn/values.yaml | 1 - 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/issue-ops.yaml create mode 100644 .github/workflows/workflow-dispatch.yaml create mode 100644 charts/drinkn/templates/github-webhooks.yaml diff --git a/.github/workflows/issue-ops.yaml b/.github/workflows/issue-ops.yaml new file mode 100644 index 000000000..98a409aa4 --- /dev/null +++ b/.github/workflows/issue-ops.yaml @@ -0,0 +1,34 @@ +name: branch-deploy + +on: + issue_comment: + types: [created] + +# Permissions needed for reacting and adding comments for IssueOps commands +permissions: + pull-requests: write + deployments: write + contents: write + checks: read + +jobs: + deploy: + name: deploy + runs-on: ubuntu-latest + if: ${{ github.event.issue.pull_request }} # only run on pull request comments + + steps: + # The branch-deploy Action + - name: branch-deploy + id: branch-deploy + uses: github/branch-deploy@v7.2.0 + + # If the branch-deploy Action was triggered, checkout our branch + - uses: actions/checkout@v3 + with: + ref: ${{ steps.branch-deploy.outputs.ref }} + + # If the branch-deploy Action was triggered, run the deployment (i.e. '.deploy') + - name: deploy + if: ${{ steps.branch-deploy.outputs.continue == 'true' && steps.branch-deploy.outputs.noop != 'true' }} + run: echo ${{ steps.branch-deploy.outputs.ref }} diff --git a/.github/workflows/workflow-dispatch.yaml b/.github/workflows/workflow-dispatch.yaml new file mode 100644 index 000000000..66b9c50cd --- /dev/null +++ b/.github/workflows/workflow-dispatch.yaml @@ -0,0 +1,17 @@ + +name: Repository Dispatch +on: + repository_dispatch: + types: [argocd] + +# permissions: +# pull-requests: write +# deployments: write +# contents: write +# checks: read + +jobs: + deployment-started: + runs-on: ubuntu-latest + steps: + - run: echo ${{ github.event.client_payload }} diff --git a/charts/drinkn/templates/github-webhooks.yaml b/charts/drinkn/templates/github-webhooks.yaml new file mode 100644 index 000000000..5a9c13976 --- /dev/null +++ b/charts/drinkn/templates/github-webhooks.yaml @@ -0,0 +1,57 @@ +{{- if .Values.pr.enabled }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: sync-hook + annotations: + argocd.argoproj.io/hook: Sync + # argocd.argoproj.io/hook: PostSync +spec: + template: + spec: + containers: + - name: curl + image: curlimages/curl:latest + env: + - name: GITHUB_TOKEN + valueFrom: + secretKeyRef: + name: github-token + key: token + command: + - "curl" + args: + - -L + - -XPOST + - -H + - "Accept: application/vnd.github+json" + - -H + - "Authorization: Bearer $GITHUB_TOKEN" + - -H + - "X-GitHub-Api-Version: 2022-11-28" + - https://api.github.com/repos/bierteam/drinkn/dispatches + - -d + - | + { + "event_type": "argocd", + "client_payload": { + "passed": false, + "message": "Error: timeout" + } + } + restartPolicy: Never + backoffLimit: 0 +--- +apiVersion: bitnami.com/v1alpha1 +kind: SealedSecret +metadata: + annotations: + argocd.argoproj.io/hook: PreSync + sealedsecrets.bitnami.com/cluster-wide: "true" + a8r.io/description: Expires on Wed, Aug 7 2024. https://github.com/settings/tokens?type=beta + name: github-token +spec: + encryptedData: + token: AgASRow85Bv/IGZTftJ5BdtnqMejgyJMNiU7z5fwJkVYZFQoc5RTYchVK5a5y4tLpT256waDcOncWavGgTsXybNo5uPUukUNE21NsCiq/Po9RtG/NYmVmJ0VeNJSVES5JYB0MPU9SsKBli1mAUWQW7gP+cVeTZCyu5Ii9SGoKOxPRMNl+8U58WAy1pYfWNimU6WA2S83VXV9IUYOqGwKfiI4Jx7na0BihiZBbMnDWXIXM+aJQ4YJoZBJ0/TtsKABJK/ictxRSdzxjzDKNTgvTBX4Vh5Nx6lTkB2++5MHqjKF+/LnuL/KawVTZhJOVw7GRxr7AW6Wuyph3l2RENwBx27IKbrPZsdKWnmS4CswpwYh0jp0pnIrs8fgPGMu+/EPP+B+Xnvd3EkLsllXQBpXKFTswF5lzQPifj+oTwi6/6m91RgsnL9hCTHlt6tEuuwB6ge9CpiRpkc0Pqki/m0JhRjR+SNbv2XhlHaXRCMnzlnbc0cyVLwM73f6/UQ7A7eyIQ3EqFwuE1x76982gi9vFAMwqUWlgIlKBe9rt+mpvBXaawvkveCTnoaJ7VgncDnl/FlmDwFGmpX6locIBNvBL3xHSC5eKZ8t6ZyfhhkEXgDPw8GA8RHX9Sute6DAXrVux+lbQ4WphEcYWwPASx0KSLz2J2pxck6OdfQERQ0zekLWF/z1lBy6aMCgMMi24bEpIE2YKCuSHk33/oRQn32LRTIsiqnPsrQk071EMOVrcgPybFsjScFpOpx9YAN9ba58glBwuohXktAbdZ24ro3wZa1K1aqWZZ2/NqwSszg8PmZxX7mSRXFkqwHV3IRZpB4= +{{- end }} diff --git a/charts/drinkn/values.yaml b/charts/drinkn/values.yaml index de873f7b3..d99b78dbe 100644 --- a/charts/drinkn/values.yaml +++ b/charts/drinkn/values.yaml @@ -9,4 +9,3 @@ fqdn: pils.oscarr.nl pr: enabled: false number: 9999 -