From ef212822feb2ec16bf129ae3aea6341d89c2e9ff Mon Sep 17 00:00:00 2001 From: Duje Begonja Date: Thu, 23 May 2024 10:28:16 +0200 Subject: [PATCH] ci: switch pr and dev env to reusable workflow --- .github/workflows/connect-button-ci.yml | 113 ++++++------------------ 1 file changed, 26 insertions(+), 87 deletions(-) diff --git a/.github/workflows/connect-button-ci.yml b/.github/workflows/connect-button-ci.yml index 0b0f4808..637bb3fd 100644 --- a/.github/workflows/connect-button-ci.yml +++ b/.github/workflows/connect-button-ci.yml @@ -52,101 +52,40 @@ jobs: deploy_pull_request: if: ${{ github.event.pull_request }} name: Deploy PR - runs-on: ubuntu-latest needs: - build_push_container - permissions: - id-token: write - contents: read - pull-requests: read - steps: - - uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main - with: - role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access' - app_name: 'connect-button' - step_name: 'deploy-pr' - secret_prefix: 'GH' - secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/jenkins-credentials-RTHKoO' - parse_json: true - - name: Connect to tailnet - uses: radixdlt/public-iac-resuable-artifacts/tailnet@main - with: - role_name: "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access" - region: "eu-west-2" - secret_name: "arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/tailscale-public-workflows-DpiE80" - - name: Trigger jenkins job to deploy PR - uses: RDXWorks-actions/jenkins-job-trigger-action@master - with: - jenkins_url: ${{ env.GH_JENKINS_URL }} - jenkins_user: ${{ env.GH_JENKINS_USER }} - jenkins_token: ${{ env.GH_JENKINS_API_TOKEN }} - job_name: ${{ env.jenkins_job_name }} - job_params: | - { - "git_repo" : "${{ github.repository }}", - "git_branch" : "${{ github.head_ref }}", - "helmfile_environment": "pr", - "hierarchical_namespace": "connect-button-ci-pr", - "namespace" : "connect-button-pr-${{ github.event.number }}", - "create_subnamespace" : "true", - "aws_region" : "eu-west-2", - "aws_iam_role": "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/jenkins-connect-button-pr-deployer", - "aws_eks_cluster" : "${{ env.dev_eks_cluster }}", - "helm_folder" : "${{ env.helm_dir }}", - "helmfile_extra_vars" : "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }},ci.prNumber=${{ github.event.number }}" - } - job_timeout: "3600" - fetch_logs: "false" - - name: Write URL to GH summary - run: | - echo "PR URL is: https://connect-button-storybook-pr-${{ github.event.number }}.rdx-works-main.extratools.works" >> $GITHUB_STEP_SUMMARY + uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@DO-2133-reusable-trigger-jenkins-action + with: + jenkins_job_name: "kubernetes-deployments/job/connect-button" + application_name: "connect-button" + hierarchical_namespace: "connect-button-ci-pr" + create_subnamespace: "true" + kubernetes_namespace: "connect-button-pr-${{ github.event.number }}" + aws_eks_cluster: "rdx-works-main-dev" + aws_iam_role_name: "jenkins-connect-button-pr-deployer" + helmfile_environment: "pr" + helmfile_extra_vars: "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }},ci.prNumber=${{ github.event.number }}" + secrets: + aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }} + secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }} deploy_dev: if: github.ref == 'refs/heads/develop' && github.event_name == 'push' name: Deploy DEV - runs-on: ubuntu-latest needs: - build_push_container - permissions: - id-token: write - contents: read - pull-requests: read - steps: - - uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main - with: - role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access' - app_name: 'connect-button' - step_name: 'deploy-dev' - secret_prefix: 'GH' - secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/jenkins-credentials-RTHKoO' - parse_json: true - - name: Connect to tailnet - uses: radixdlt/public-iac-resuable-artifacts/tailnet@main - with: - role_name: "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access" - region: "eu-west-2" - secret_name: "arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/tailscale-public-workflows-DpiE80" - - name: Trigger jenkins job to deploy DEV - uses: RDXWorks-actions/jenkins-job-trigger-action@master - with: - jenkins_url: ${{ env.GH_JENKINS_URL }} - jenkins_user: ${{ env.GH_JENKINS_USER }} - jenkins_token: ${{ env.GH_JENKINS_API_TOKEN }} - job_name: ${{ env.jenkins_job_name }} - job_params: | - { - "git_repo" : "${{ github.repository }}", - "git_branch" : "${{ github.head_ref }}", - "helmfile_environment": "dev", - "namespace" : "connect-button-dev", - "aws_region" : "eu-west-2", - "aws_iam_role": "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/jenkins-connect-button-dev-deployer", - "aws_eks_cluster" : "${{ env.dev_eks_cluster }}", - "helm_folder" : "${{ env.helm_dir }}", - "helmfile_extra_vars" : "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }}" - } - job_timeout: "3600" - fetch_logs: "false" + uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@DO-2133-reusable-trigger-jenkins-action + with: + jenkins_job_name: "kubernetes-deployments/job/connect-button" + application_name: "connect-button" + kubernetes_namespace: "connect-button" + aws_eks_cluster: "rdx-works-main-dev" + aws_iam_role_name: "jenkins-connect-button-dev-deployer" + helmfile_environment: "dev" + helmfile_extra_vars: "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }}" + secrets: + aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }} + secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }} deploy_prod: if: github.ref == 'refs/heads/main' && github.event_name == 'push'