Skip to content

Commit

Permalink
ci: switch pr and dev env to reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
duje-begonja-rdx committed May 23, 2024
1 parent f05a511 commit ef21282
Showing 1 changed file with 26 additions and 87 deletions.
113 changes: 26 additions & 87 deletions .github/workflows/connect-button-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit ef21282

Please sign in to comment.