diff --git a/create-jira-deployment/action.yml b/create-jira-deployment/action.yml index 9be5812b..3a989364 100644 --- a/create-jira-deployment/action.yml +++ b/create-jira-deployment/action.yml @@ -5,12 +5,23 @@ description: | envInputs: JENKINS_USER: Jenkins user JENKINS_BUILD_TOKEN: Jenkins build token. Keep in mind that tokens for `temploy` and `staging` differ - PROXY: Proxy to use for Jenkins inputs: - token: + # token: + # required: true + # description: 'GitHub token to create a deployment' + jenkins_build_url: + description: 'Jenkins build instance URL' + required: true + jenkins_build_user: + description: 'Jenkins build user' + required: true + jenkins_build_token: + description: 'Jenkins build token' + required: true + jenkins_sa_credentials: + description: 'Jenkins service account credentials to use with IAP' required: true - description: 'GitHub token to create a deployment' environment-url: required: false description: 'URL of the environment' @@ -30,64 +41,65 @@ inputs: default: 'false' description: Creates a Github Deployment along with JIRA Deployment - runs: using: composite steps: - - uses: chrnorm/deployment-action@v2 - name: Create GitHub deployment - id: gh-deployment - if: ${{ always() && inputs.create-gh-deployment == 'true' }} - with: - token: ${{ inputs.token }} - environment-url: ${{ inputs.environment-url }} - environment: ${{ inputs.environment }} - transient-environment: ${{ inputs.transient-environment }} - auto-inactive: ${{ inputs.auto-inactive }} + # - uses: chrnorm/deployment-action@v2 + # name: Create GitHub deployment + # id: gh-deployment + # if: ${{ always() && inputs.create-gh-deployment == 'true' }} + # with: + # token: ${{ inputs.token }} + # environment-url: ${{ inputs.environment-url }} + # environment: ${{ inputs.environment }} + # transient-environment: ${{ inputs.transient-environment }} + # auto-inactive: ${{ inputs.auto-inactive }} - - name: Update deployment status on success - if: ${{ success() && inputs.create-gh-deployment == 'true' }} - uses: chrnorm/deployment-status@v2 - with: - token: ${{ inputs.token }} - environment-url: ${{ steps.gh-deployment.outputs.environment_url }} - deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }} - log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - state: 'success' + # - name: Update deployment status on success + # if: ${{ success() && inputs.create-gh-deployment == 'true' }} + # uses: chrnorm/deployment-status@v2 + # with: + # token: ${{ inputs.token }} + # environment-url: ${{ steps.gh-deployment.outputs.environment_url }} + # deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }} + # log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + # state: 'success' - - name: Update deployment status on failure - if: ${{ failure() && inputs.create-gh-deployment == 'true' }} - uses: chrnorm/deployment-status@v2 - with: - token: ${{ inputs.token }} - environment-url: ${{ steps.gh-deployment.outputs.environment_url }} - deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }} - log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - state: 'failure' + # - name: Update deployment status on failure + # if: ${{ failure() && inputs.create-gh-deployment == 'true' }} + # uses: chrnorm/deployment-status@v2 + # with: + # token: ${{ inputs.token }} + # environment-url: ${{ steps.gh-deployment.outputs.environment_url }} + # deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }} + # log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + # state: 'failure' - - name: Set appName - id: repo - if: ${{ always() }} - shell: bash - run: | - echo APP_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) >> $GITHUB_OUTPUT + # - name: Set appName + # id: repo + # if: ${{ always() }} + # shell: bash + # run: | + # echo APP_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) >> $GITHUB_OUTPUT - - id: sha - uses: toptal/davinci-github-actions/get-workflow-sha@master + # - id: sha + # uses: toptal/davinci-github-actions/get-workflow-sha@master - name: Trigger `Create JIRA` deployment - uses: toptal/jenkins-job-trigger-action@1.0.1 + uses: toptal/actions/trigger-jenkins-job@main if: ${{ always() }} with: - jenkins_url: https://jenkins-build.toptal.net/ - jenkins_user: ${{ env.JENKINS_USER }} - jenkins_token: ${{ env.JENKINS_BUILD_TOKEN }} - proxy: ${{ env.PROXY }} - job_name: create-jira-deployment - job_params: | - { - "appName": "${{ steps.repo.outputs.APP_NAME }}", - "envName": "${{ inputs.environment }}", - "sha": "${{ github.event.pull_request.head.sha || steps.sha.outputs.result }}" - } + jenkins_url: ${{ inputs.jenkins_build_url }} + jenkins_user: ${{ inputs.jenkins_build_user }} + jenkins_token: ${{ inputs.jenkins_build_token }} + jenkins_client_id: ${{ inputs.jenkins_client_id }} + jenkins_sa_credentials: ${{ inputs.jenkins_sa_credentials }} + # job_name: create-jira-deployment + # job_params: | + # { + # "appName": "${{ steps.repo.outputs.APP_NAME }}", + # "envName": "${{ inputs.environment }}", + # "sha": "${{ github.event.pull_request.head.sha || steps.sha.outputs.result }}" + # } + job_name: job-test-iap job_timeout: '3600' diff --git a/deploy-storybook/action.yml b/deploy-storybook/action.yml index 9d054d8e..d6773f28 100644 --- a/deploy-storybook/action.yml +++ b/deploy-storybook/action.yml @@ -6,10 +6,28 @@ description: | GITHUB_TOKEN: GitHub token. Is used to checkout `davinci` branch GCR_ACCOUNT_KEY: Necessary token to push image to Google cloud GCR_GQL_SCHEMAS_BUCKET_TOKEN: Necessary token to pull GQL schema from Google Cloud - JENKINS_DEPLOY_TOKEN: Jenkins deployment token. Keep in mind that tokens for `temploy` and `staging` differ - NPM_TOKEN: Necessary token to install private dependencies + NPM_TOKEN: Necessary token to install private dependencies +# JENKINS_DEPLOY_TOKEN: Jenkins deployment token. Keep in mind that tokens for `temploy` and `staging` differ inputs: + jenkins_url: + description: 'Jenkins main instance URL' + required: true + jenkins_build_url: + description: 'Jenkins build instance URL' + required: true + jenkins_user: + description: 'Jenkins main user' + required: true + jenkins_token: + description: 'Jenkins main token' + required: true + jenkins_client_id: + description: 'Jenkins Client ID used with IAP' + required: true + jenkins_sa_credentials: + description: 'Jenkins service account credentials to use with IAP' + required: true sha: description: Commit hash that will be used as a tag for the Docker image required: true @@ -50,133 +68,139 @@ inputs: pr-number: description: Event number of the original pr, in case event number or issue number is not present. . required: false - default: false + default: 'false' checkout-token: description: Repository checkout access token `GITHUB_TOKEN`. Required for self hosted runners required: false node-version: required: false - default: 18 + default: '18' description: 'Node.js version used. The action is guaranteed to work only with Node.js@18 (default value)' runs: using: composite steps: - - name: Set up node - uses: actions/setup-node@v3 - with: - node-version: ${{ inputs.node-version }} + # - name: Set up node + # uses: actions/setup-node@v3 + # with: + # node-version: ${{ inputs.node-version }} - - name: Install Dependencies - if: ${{ inputs.use-prebuilt-package == 'false' && inputs.use-prebuilt-image == 'false' }} - uses: toptal/davinci-github-actions/yarn-install@v6.0.0 - with: - checkout-token: ${{ inputs.checkout-token }} + # - name: Install Dependencies + # if: ${{ inputs.use-prebuilt-package == 'false' && inputs.use-prebuilt-image == 'false' }} + # uses: toptal/davinci-github-actions/yarn-install@v6.0.0 + # with: + # checkout-token: ${{ inputs.checkout-token }} - - name: Generate Types - if: ${{ inputs.generate-types-command != 'false' }} - uses: toptal/davinci-github-actions/generate-gql-types@v6.0.0 - with: - generate-types-command: ${{ inputs.generate-types-command }} - gcr-gql-schemas-bucket-token: ${{ env.GCR_GQL_SCHEMAS_BUCKET_TOKEN }} + # - name: Generate Types + # if: ${{ inputs.generate-types-command != 'false' }} + # uses: toptal/davinci-github-actions/generate-gql-types@v6.0.0 + # with: + # generate-types-command: ${{ inputs.generate-types-command }} + # gcr-gql-schemas-bucket-token: ${{ env.GCR_GQL_SCHEMAS_BUCKET_TOKEN }} - - name: Build Storybook - if: ${{ inputs.use-prebuilt-package == 'false' && inputs.use-prebuilt-image == 'false' }} - shell: bash - env: - BUILD_COMMAND: ${{ inputs.build-command }} - run: yarn "$BUILD_COMMAND" + # - name: Build Storybook + # if: ${{ inputs.use-prebuilt-package == 'false' && inputs.use-prebuilt-image == 'false' }} + # shell: bash + # env: + # BUILD_COMMAND: ${{ inputs.build-command }} + # run: yarn "$BUILD_COMMAND" - - name: Specify Repository, Jenkins folder and Release Name - id: repo - shell: bash - env: - FOLDER_NAME: ${{ inputs.jenkins-folder-name }} - EVENT_NUMBER: ${{ github.event.number || github.event.issue.number || inputs.pr-number }} - run: | - folder_name=$FOLDER_NAME + # - name: Specify Repository, Jenkins folder and Release Name + # id: repo + # shell: bash + # env: + # FOLDER_NAME: ${{ inputs.jenkins-folder-name }} + # EVENT_NUMBER: ${{ github.event.number || github.event.issue.number || inputs.pr-number }} + # run: | + # folder_name=$FOLDER_NAME - if [[ "$folder_name" == '' ]]; then - echo folder_name=${{ github.event.repository.name }} >> $GITHUB_OUTPUT - else - echo folder_name=$FOLDER_NAME >> $GITHUB_OUTPUT - fi + # if [[ "$folder_name" == '' ]]; then + # echo folder_name=${{ github.event.repository.name }} >> $GITHUB_OUTPUT + # else + # echo folder_name=$FOLDER_NAME >> $GITHUB_OUTPUT + # fi - echo "repository_name=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT - echo "release_name=${{ github.event.repository.name }}-pr-$EVENT_NUMBER-storybook" >> $GITHUB_OUTPUT - echo "pr_number=${{ inputs.pr-number }}" >> $GITHUB_OUTPUT - - - name: Build and Push Storybook Image - uses: toptal/davinci-github-actions/build-push-image@v6.0.0 - if: ${{ inputs.use-prebuilt-image == 'false' }} - with: - sha: ${{ inputs.sha }} - image-name: ${{ steps.repo.outputs.repository_name }}-storybook-release - build-args: | - DIST_FOLDER=${{ inputs.dist-folder }} - NGINX_CONFIG=./davinci/packages/davinci/docker/nginx-vhost.conf - ENV_RUNTIME_ENTRYPOINT=./davinci/packages/ci/src/configs/docker/env-runtime.entrypoint.sh - VERSION=${{ inputs.sha }} - docker-file: ./davinci/packages/ci/src/configs/docker/Dockerfile.gha-deploy - davinci-branch: ${{ inputs.davinci-branch }} + # echo "repository_name=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT + # echo "release_name=${{ github.event.repository.name }}-pr-$EVENT_NUMBER-storybook" >> $GITHUB_OUTPUT + # echo "pr_number=${{ inputs.pr-number }}" >> $GITHUB_OUTPUT + + # - name: Build and Push Storybook Image + # uses: toptal/davinci-github-actions/build-push-image@v6.0.0 + # if: ${{ inputs.use-prebuilt-image == 'false' }} + # with: + # sha: ${{ inputs.sha }} + # image-name: ${{ steps.repo.outputs.repository_name }}-storybook-release + # build-args: | + # DIST_FOLDER=${{ inputs.dist-folder }} + # NGINX_CONFIG=./davinci/packages/davinci/docker/nginx-vhost.conf + # ENV_RUNTIME_ENTRYPOINT=./davinci/packages/ci/src/configs/docker/env-runtime.entrypoint.sh + # VERSION=${{ inputs.sha }} + # docker-file: ./davinci/packages/ci/src/configs/docker/Dockerfile.gha-deploy + # davinci-branch: ${{ inputs.davinci-branch }} - name: Trigger Deploy to Staging if: ${{ inputs.environment == 'staging' }} - uses: toptal/jenkins-job-trigger-action@1.0.1 + uses: toptal/actions/trigger-jenkins-job@main env: JENKINS_FOLDER_NAME: ${{ steps.repo.outputs.folder_name }} REPOSITORY_NAME: ${{ steps.repo.outputs.repository_name }} with: - jenkins_url: https://jenkins.toptal.net - jenkins_user: toptal-devbot - jenkins_token: ${{ env.JENKINS_DEPLOY_TOKEN }} - job_name: ${{ env.JENKINS_FOLDER_NAME }}/job/${{ env.REPOSITORY_NAME }}-storybook-staging-deployment - job_params: | - { - "TAG": "${{ inputs.sha }}" - } + jenkins_url: ${{ inputs.jenkins_url }} + jenkins_user: ${{ inputs.jenkins_user }} ##toptal-devbot + jenkins_token: ${{ inputs.jenkins_token }} ##${{ env.JENKINS_DEPLOY_TOKEN }} + jenkins_client_id: ${{ inputs.jenkins_client_id }} + jenkins_sa_credentials: ${{ inputs.jenkins_sa_credentials }} + # job_name: ${{ env.JENKINS_FOLDER_NAME }}/job/${{ env.REPOSITORY_NAME }}-storybook-staging-deployment + # job_params: | + # { + # "TAG": "${{ inputs.sha }}" + # } + job_name: job-test-iap job_timeout: 1200 - - uses: toptal/davinci-github-actions/extract-env-variables@v6.0.0 - if: ${{ inputs.environment == 'temploy' }} - id: env-variables - with: - github-token: ${{ env.GITHUB_TOKEN }} - filename: ${{ inputs.env-file }} + # - uses: toptal/davinci-github-actions/extract-env-variables@v6.0.0 + # if: ${{ inputs.environment == 'temploy' }} + # id: env-variables + # with: + # github-token: ${{ env.GITHUB_TOKEN }} + # filename: ${{ inputs.env-file }} - name: Trigger Deploy to Temploy - if: ${{ inputs.environment == 'temploy' }} - uses: toptal/jenkins-job-trigger-action@1.0.1 +# if: ${{ inputs.environment == 'temploy' }} + uses: toptal/actions/trigger-jenkins-job@main env: JENKINS_FOLDER_NAME: ${{ steps.repo.outputs.folder_name }} REPOSITORY_NAME: ${{ steps.repo.outputs.repository_name }} RELEASE: ${{ steps.repo.outputs.release_name }} with: - jenkins_url: https://jenkins-build.toptal.net/ + jenkins_url: ${{ inputs.jenkins_build_url }} jenkins_user: toptal-jenkins - jenkins_token: ${{ env.JENKINS_DEPLOY_TOKEN }} - job_name: ${{ env.JENKINS_FOLDER_NAME }}/job/${{ env.REPOSITORY_NAME }}-storybook-temploy-helm-run - job_params: | - { - "REPOSITORY_NAME": "${{ env.REPOSITORY_NAME }}-storybook", - "RELEASE": "${{ env.RELEASE }}", - "TAG": "${{ inputs.sha }}", - "ENV": "${{ steps.env-variables.outputs.variables || 'ENV=null' }}" - } + jenkins_token: ${{ inputs.jenkins_token }} ###${{ env.JENKINS_DEPLOY_TOKEN }} + jenkins_client_id: ${{ inputs.jenkins_client_id }} + jenkins_sa_credentials: ${{ inputs.jenkins_sa_credentials }} + # job_name: ${{ env.JENKINS_FOLDER_NAME }}/job/${{ env.REPOSITORY_NAME }}-storybook-temploy-helm-run + # job_params: | + # { + # "REPOSITORY_NAME": "${{ env.REPOSITORY_NAME }}-storybook", + # "RELEASE": "${{ env.RELEASE }}", + # "TAG": "${{ inputs.sha }}", + # "ENV": "${{ steps.env-variables.outputs.variables || 'ENV=null' }}" + # } + job_name: job-test-iap job_timeout: 1200 - - name: Post Temploy Link - if: ${{ inputs.environment == 'temploy' }} - uses: actions/github-script@v6.3.3 - env: - RELEASE: ${{ steps.repo.outputs.release_name }} - PR_NUMBER: ${{ steps.repo.outputs.pr_number }} - with: - github-token: ${{ env.GITHUB_TOKEN }} - script: | - const trimSuffix = (name) => name.endsWith('-') ? name.slice(0, -1) : name - const { issue: { number: issue_number }, repo: { owner, repo } } = context - const name = trimSuffix(['${{ env.RELEASE }}', '${{ steps.repo.outputs.repository_name }}-storybook'].join('-').substring(0, 45)) - const body = `Storybook temploy is available at https://${name}.toptal.rocks :tada:` - const number = issue_number || ${{ env.PR_NUMBER }} - github.rest.issues.createComment({ issue_number: number, owner, repo, body }) + # - name: Post Temploy Link + # if: ${{ inputs.environment == 'temploy' }} + # uses: actions/github-script@v6.3.3 + # env: + # RELEASE: ${{ steps.repo.outputs.release_name }} + # PR_NUMBER: ${{ steps.repo.outputs.pr_number }} + # with: + # github-token: ${{ env.GITHUB_TOKEN }} + # script: | + # const trimSuffix = (name) => name.endsWith('-') ? name.slice(0, -1) : name + # const { issue: { number: issue_number }, repo: { owner, repo } } = context + # const name = trimSuffix(['${{ env.RELEASE }}', '${{ steps.repo.outputs.repository_name }}-storybook'].join('-').substring(0, 45)) + # const body = `Storybook temploy is available at https://${name}.toptal.rocks :tada:` + # const number = issue_number || ${{ env.PR_NUMBER }} + # github.rest.issues.createComment({ issue_number: number, owner, repo, body })