-
Notifications
You must be signed in to change notification settings - Fork 25
80 lines (73 loc) · 3.39 KB
/
deploy-to-QA.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Deploy To QA
on:
workflow_call:
jobs:
Deploy-to-QA:
runs-on: ubuntu-latest
environment: Staging
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_DEV_GITHUB_TOKEN }}
persist-credentials: true
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install dependency
run: |
npm i rimraf
- name: Setup Git Authentication
env:
COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }}
COMMIT_EMAIL: ${{ secrets.CI_COMMIT_EMAIL }}
MY_PERSONAL_ACCESS_TOKEN: ${{ secrets.CI_DEV_GITHUB_TOKEN }}
run: |
git config --global user.name $COMMIT_AUTHOR
git config --global user.email $COMMIT_EMAIL
git config --global credential.helper 'cache --timeout=300'
git config --global --add "credential.https://github.com.username" "x-access-token"
echo "https://x-access-token:[email protected]" > ~/.git-credentials
- uses: mdecoleman/[email protected]
id: vars
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Export branch name
run: |
echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV
- name: Check if fixed version is on Jira
env:
JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
fixed_version_found=false
plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
jira_fixed_version="Capacitor SDK v$plugin_version"
echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV
echo "JIRA_FIXED_VERSION=$jira_fixed_version" >> $GITHUB_ENV
chmod +x .github/workflows/scripts/releaseNotesGenerator.sh
.github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$jira_fixed_version"
- name: Build Plugin
run: |
npm run build
- name: Push to NPM
env:
CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc
npm publish --tag QA
- name: Generate and send slack report
env:
SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }}
JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }}
JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}"
RELEASE_BRANCH_NAME: ${{env.RELEASE_BRANCH_NAME}}
run: |
ANDROID_SDK_VERSION=`cat package.json | jq .androidSdkVersion`
IOS_SDK_VERSION=`cat package.json | jq .iosSdkVersion`
PLUGIN_VERSION=`cat package.json | jq .version`
BUILD_NUMBER=`cat package.json | jq .buildNumber`
chmod +x .github/workflows/scripts/releaseNotesGenerator.sh
.github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION"
CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt)
curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"$JIRA_FIXED_VERSION"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"$ANDROID_SDK_VERSION"'", "ios_dependency": "'"$IOS_SDK_VERSION"'"}' "$SLACK_TOKEN"