Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ulricden committed Sep 13, 2023
1 parent 3d5197d commit 685be5b
Show file tree
Hide file tree
Showing 12 changed files with 365 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
name: Build Design System Storybook App

on:
push:
branches:
- main
pull_request:
release:
types: [created]
workflow_call:
inputs:
version-code:
required: true
type: string
node-version:
required: true
type: string
java-version:
required: true
type: string
outputs:
apk-name:
description: 'Apk name'
value: app-release.apk
apk-version:
description: 'Apk version'
value: ${{ jobs.build.outputs.apk-version }}
apk-artifact-name:
description: 'Apk artifact name'
value: Design-System-Samples-Apk

jobs:
build:
Expand All @@ -18,8 +33,6 @@ jobs:
working-directory: ./Storybook
env:
smartway_keystore_name: smartway.keystore
node-version: 18
java-version: 11
steps:
- name: Tailscale
uses: tailscale/github-action@v2
Expand All @@ -30,17 +43,14 @@ jobs:
version: ${{ vars.TAILSCALE_VERSION }}

- name: Import Secrets
id: secrets
id: import-secrets
uses: hashicorp/vault-action@v2
with:
url: ${{ vars.VAULT_URL }}
role: ${{ vars.VAULT_GITHUB_ACTIONS_ROLE }}
method: jwt
path: 'github-actions'
secrets: |
secret/data/smartapp/keystore KEYSTORE_PASSWORD | SMARTWAY_KEYSTORE_PASSWORD ;
secret/data/smartapp/keystore KEYSTORE_PASSWORD | SMARTWAY_KEY_PASSWORD ;
secret/data/smartapp/keystore KEY_ALIAS | SMARTWAY_KEY_ALIAS ;
secret/data/github-actions-common/aws accessKey | AWS_ACCESS_KEY_ID ;
secret/data/github-actions-common/aws secretKey | AWS_SECRET_ACCESS_KEY ;
Expand All @@ -49,7 +59,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
node-version: ${{ inputs.node-version }}
registry-url: 'https://npm.pkg.github.com'
scope: '@ZeroGachis'

Expand All @@ -60,7 +70,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ env.java-version }}
java-version: ${{ inputs.java-version }}
cache: 'gradle'

- name: Validate Gradle wrapper
Expand All @@ -72,13 +82,19 @@ jobs:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ steps.secrets.outputs.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.secrets.outputs.AWS_SECRET_ACCESS_KEY }}
aws-access-key-id: ${{ steps.import-secrets.outputs.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.import-secrets.outputs.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1

- name: Get Smartway APK keystore
run: aws s3 cp s3://backup-zerogachis/github-actions/${{ env.smartway_keystore_name }} android/app/${{ env.smartway_keystore_name }}

- name: Update android versions
uses: chkfung/android-version-actions@v1
with:
gradlePath: android/app/build.gradle
versionCode: ${{ inputs.version-code }}

- name: Install dependencies
run: npm install
env:
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Build Design System package

on:
workflow_call:
push:
branches:
- main
pull_request:
release:
types: [created]

jobs:
build:
Expand Down Expand Up @@ -41,9 +40,3 @@ jobs:

- name: Compile
run: npm run tsc

- name: Publish
if: startsWith(github.ref, 'refs/tags/')
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check apk version

on:
workflow_call:
outputs:
is-new-apk-version:
value: ${{ jobs.need-new-version-apk.outputs.need-new-apk }}
env:
apk_name: app-release.apk

jobs:
need-new-version-apk:
runs-on: [ubuntu-latest]
outputs:
need-new-apk: ${{ steps.get-existing-apk.outputs.need-new-apk }}
steps:
- name: Get APK version
id: get-apk-version
run: |
echo "apk-version=$(grep -oP "versionName \"\K[^\"]*" android/app/build.gradle)" >> $GITHUB_OUTPUT
- name: Get existing APK
id: get-existing-apk
run: |
aws s3 cp s3://${{ vars.S3_BUCKET }}/storybook-smartapp/${{ steps.get-apk-version.outputs.apk-version }}/${{ env.apk_name }} android/app/build/outputs/apk/release/${{ env.apk_name }} && {
echo "Apk already exist for that version"
echo "need-new-apk=false" >> $GITHUB_OUTPUT
} || {
echo "Apk does not exist for that version, need build a new one"
echo "need-new-apk=true" >> $GITHUB_OUTPUT
}
20 changes: 20 additions & 0 deletions .github/workflows/format-version-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'FormatVersionCode'

on:
workflow_call:
outputs:
version-code:
description: 'Version code generated'
value: ${{ jobs.format-version-code.outputs.version-code }}

jobs:
format-version-code:
name: Format Version Code
runs-on: ubuntu-latest

outputs:
version-code: ${{ steps.version-code.outputs.value }}
steps:
- name: 'Format build number for Android VersionCode'
id: version-code
run: echo "value=`printf '%04o\n' ${{ github.run_number }}`" >> $GITHUB_OUTPUT
64 changes: 64 additions & 0 deletions .github/workflows/publish-bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 'Bundle JS'

on:
workflow_call:
inputs:
node-version:
required: true
type: string
codepush-app:
required: true
type: string

jobs:
bundle-js:
runs-on: ubuntu-latest
steps:
- name: Import Secrets
id: imported-secrets
uses: hashicorp/vault-action@v2
with:
url: ${{ vars.VAULT_URL }}
role: ${{ vars.VAULT_GITHUB_ACTIONS_ROLE }}
method: jwt
path: 'github-actions'
secrets: |
secret/data/storybook-smartapp CODE_PUSH_KEY_NAME | STORYBOOK_CODE_PUSH_KEY_NAME ;
secret/data/storybook-smartapp CODE_PUSH_TOKEN | STORYBOOK_CODE_PUSH_TOKEN ;
- name: Clean Workspace
uses: mickem/clean-after-action@v2

- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
registry-url: 'https://npm.pkg.github.com'
scope: '@ZeroGachis'

- name: Install dependencies
run: npm ci --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Rebuild & Prepare dependencies
run: npm rebuild && npm run prepare --if-present

- name: Install App center
run: npm install -g appcenter-cli

- name: App center login
run: appcenter login --token ${{ steps.imported-secrets.outputs.STORYBOOK_CODE_PUSH_TOKEN }}

- name: Deploy code push
run: |
appcenter codepush release-react -a ${{ inputs.codepush-app }} -d ${{ steps.imported-secrets.outputs.STORYBOOK_CODE_PUSH_KEY_NAME }} || {
if [[ $? -eq 3 ]] ; then
echo "Code push deploy skipped."
exit 0
fi
exit $?
}
40 changes: 40 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
tags:
- '*'

jobs:
publish:
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@ZeroGachis'

- name: Install dependencies
run: npm ci --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Rebuild & Prepare dependencies
run: npm rebuild && npm run prepare --if-present

- name: Update package version
uses: mingjun97/file-regex-replace@v1
with:
regex: '"version": "([0-9.]*)"'
replacement: '"version": "${{ github.ref_name }}"'
include: 'package.json'

- name: Compile
run: npm run tsc

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/publish-s3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish S3

on:
workflow_call:
inputs:
apk-artifact-name:
required: true
type: string
apk-name:
required: true
type: string
apk-version:
required: true
type: string

jobs:
publish-s3:
runs-on: [ubuntu-latest]
steps:
- name: Clean Workspace
uses: mickem/clean-after-action@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1

- name: Download Artefact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: ${{ github.workspace }}/artifact/

- name: Push Apk to S3
working-directory: 'artifact'
run: aws s3 cp ${{ inputs.apk-name }} s3://${{ vars.S3_BUCKET }}/react-native/${{ inputs.apk-version }}/${{ inputs.apk-name }}
44 changes: 44 additions & 0 deletions .github/workflows/publish-soti.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish Soti

on:
workflow_call:
inputs:
environment:
required: true
type: string
apk-name:
required: true
type: string
apk-artifact-name:
required: true
type: string
jobs:
publish-soti:
name: Publish APK on Soti
environment: ${{ inputs.environment }}
runs-on: [self-hosted, python]

steps:
- name: Clean Workspace
uses: mickem/clean-after-action@v2

- name: Checkout
uses: actions/checkout@v3

- name: Download APK
uses: actions/download-artifact@v3
with:
name: ${{ inputs.apk-artifact-name }}
path: ${{ github.workspace }}/artifact/

- name: Publish APK on SOTI
working-directory: scripts/soti
run: |
pip3 install --user -r requirements.txt \
&& python3 upload-package.py \
"${{ secrets.SOTI_API_URL }}" \
"${{ github.workspace }}/artifact/${{ inputs.apk-name }}" \
"${{ secrets.SOTI_API_KEY }}" \
"${{ secrets.SOTI_API_SECRET }}" \
"${{ secrets.SOTI_USERNAME }}" \
"${{ secrets.SOTI_PASSWORD }}"
Loading

0 comments on commit 685be5b

Please sign in to comment.