Skip to content

ci: upgrade create-jira-deployment version (#3854) #1278

ci: upgrade create-jira-deployment version (#3854)

ci: upgrade create-jira-deployment version (#3854) #1278

Workflow file for this run

name: Release
on:
workflow_dispatch:
push:
branches:
- master
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
TOPTAL_BOT_USERNAME: ${{ secrets.TOPTAL_TRIGGERBOT_USERNAME }}
TOPTAL_BOT_JENKINS_DEPLOYMENT_TOKEN: ${{ secrets.TOPTAL_TRIGGERBOT_DEPLOYMENT_TOKEN }}
TOPTAL_JENKINS_BUILD_TOKEN: ${{ secrets.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}
HTTP_PROXY: http://${{ secrets.HTTP_PROXY }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
DEVBOT_TOKEN: ${{ secrets.TOPTAL_DEVBOT_TOKEN }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
# This forces changesets to use git user, provided by GITHUB_TOKEN env var
persist-credentials: false
- name: Setup node 16
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Check yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies (from network)
if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
run: |
yarn policies set-version
yarn install --frozen-lockfile --ignore-optional
- name: Install Dependencies (from cache)
if: ${{ steps.yarn-cache.outputs.cache-hit == 'true' }}
run: |
yarn policies set-version
yarn install --frozen-lockfile --ignore-optional --offline
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@e9cc34b540dd3ad1b030c57fd97269e8f6ad905a
with:
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.TOPTAL_BUILD_BOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH }}
- name: Edit "Version Package" PR
if: ${{ steps.changesets.outputs.published != 'true' }}
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Get list of all open PRs with
// head branch "changeset-release/master"
// (there should be max 1 PR with such condition)
const { data } = await github.rest.pulls.list({
owner: 'toptal',
repo: 'picasso',
state: 'open',
head: 'toptal:changeset-release/master'
})
for await (let pr of data) {
// add to all of them label "no-jira"
github.rest.issues.addLabels({
owner: 'toptal',
repo: 'picasso',
issue_number: pr.number,
labels: [
'no-jira'
]
})
// append PR body with peerDependencies warning
const hr = "\n_____"
const warningTodo = "\n- [ ] ⚠️ "
const message = "If major release, don't forget to check if peerDependencies needs to be also updated"
const appendedMessage = hr + warningTodo + message
const body = pr.body.includes(message) ? pr.body : pr.body + appendedMessage
github.rest.pulls.update({
owner: 'toptal',
repo: 'picasso',
pull_number: pr.number,
body: body,
})
}
- name: Trigger build image job
uses: toptal/[email protected]
id: trigger-build
env:
JENKINS_JOB_NAME: ${{ env.REPOSITORY_NAME }}-build-image
JENKINS_USER: ${{ secrets.TOPTAL_TRIGGERBOT_USERNAME }}
with:
jenkins_url: https://jenkins-build.toptal.net/
jenkins_user: ${{ env.JENKINS_USER }}
jenkins_token: ${{ env.TOPTAL_JENKINS_BUILD_TOKEN }}
proxy: ${{ env.HTTP_PROXY }}
job_name: ${{ env.JENKINS_JOB_NAME }}
job_params: |
{
"BRANCH": "master",
"VERSION": "${{ github.sha }}",
"IMAGE_NAME": "${{ env.REPOSITORY_NAME }}"
}
job_timeout: '3600'
- name: Trigger deployment job
id: trigger-deploy
uses: toptal/[email protected]
env:
JENKINS_JOB_NAME: ${{ env.REPOSITORY_NAME }}-docs
with:
jenkins_url: https://jenkins-deployment.toptal.net/
jenkins_user: ${{ env.TOPTAL_BOT_USERNAME }}
jenkins_token: ${{ env.TOPTAL_BOT_JENKINS_DEPLOYMENT_TOKEN }}
proxy: ${{ env.HTTP_PROXY }}
job_name: ${{ env.JENKINS_JOB_NAME }}
job_params: |
{
"COMMIT_ID": "${{ github.sha }}"
}
job_timeout: '3600'
- name: Send a Slack notification on failure
if: ${{ failure() }}
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ env.SLACK_BOT_TOKEN }}
FAILURE_URL: ${{ steps.trigger-deploy.outputs.jenkins_job_url || steps.trigger-build.outputs.jenkins_job_url }}
FALLBACK_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?check_suite_focus=true
with:
channel-id: '-frontend-exp-team-notifications'
slack-message: ':x: <!here> Current master version of Picasso is <${{ env.FAILURE_URL || env.FALLBACK_URL }}|broken>.'
- name: Send a Slack notification on success release
if: ${{ success() && steps.changesets.outputs.published == 'true' }}
uses: slackapi/[email protected]
with:
channel-id: '-frontend-exp-team-notifications'
slack-message: 'Current master version of Picasso successfully released :green_heart:'
env:
SLACK_BOT_TOKEN: ${{ env.SLACK_BOT_TOKEN }}
- name: Send a Slack notification on success PR merge
if: ${{ success() && steps.changesets.outputs.published != 'true'}}
uses: slackapi/[email protected]
with:
channel-id: '-frontend-exp-team-notifications'
slack-message: 'A new PR was merged to Picasso :parrotspin:'
env:
SLACK_BOT_TOKEN: ${{ env.SLACK_BOT_TOKEN }}
- uses: toptal/davinci-github-actions/[email protected]
name: Create Jira deployment
if: ${{ steps.changesets.outputs.published == 'true' }}
env:
JENKINS_USER: ${{ secrets.TOPTAL_TRIGGERBOT_USERNAME }}
JENKINS_BUILD_TOKEN: ${{ secrets.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}
PROXY: http://${{ secrets.HTTP_PROXY }}
with:
token: ${{ env.DEVBOT_TOKEN }}
environment: production
environment-url: https://www.npmjs.com/package/@toptal/picasso?activeTab=versions
integration-tests:
name: Integration Tests
uses: ./.github/workflows/davinci-integration-tests.yml
secrets:
TOPTAL_DEVBOT_TOKEN: ${{ secrets.TOPTAL_DEVBOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
HAPPO_API_KEY: ${{ secrets.HAPPO_API_KEY }}
HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }}