fix: yfinance on cloud workaround #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release branch CICD | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
pre_check: | |
name: Test and semver | |
runs-on: ubuntu-latest | |
outputs: | |
new_release_published: ${{ steps.semantic.outputs.new_release_published }} | |
new_release_version: ${{ steps.semantic.outputs.new_release_version }} | |
defaults: | |
run: | |
working-directory: ./client | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Node (16) | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
cache-dependency-path: client/package-lock.json | |
- name: NPM ci | |
run: npm ci | |
- name: Test | |
run: npx quasar test --unit jest | |
- name: Semantic Release | |
id: semantic | |
uses: cycjimmy/semantic-release-action@v3 | |
with: | |
semantic_version: 19.0.5 | |
dry_run: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Version check | |
if: ${{ steps.semantic.outputs.new_release_published == 'true' }} | |
run: echo "Preparing version ${{ steps.semantic.outputs.new_release_version }}" | |
build: | |
name: Build front-end | |
needs: [ pre_check ] | |
if: needs.pre_check.outputs.new_release_published == 'true' | |
outputs: | |
new_release_published: ${{ needs.pre_check.outputs.new_release_published }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./client | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Node (16) | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
cache-dependency-path: client/package-lock.json | |
- name: NPM ci | |
run: npm ci | |
- name: Semantic Release | |
id: semantic | |
uses: cycjimmy/semantic-release-action@v3 | |
with: | |
semantic_version: 19.0.5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set package.json version | |
run: npm version ${{ steps.semantic.outputs.new_release_version }} --no-git-tag-version | |
- name: Build | |
run: npx quasar build --publish sentry | |
- name: Determine version | |
run: echo "SOURCE_VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV | |
- name: Determine version | |
run: echo "Deploying version $SOURCE_VERSION" | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
# SENTRY_URL: https://sentry.io/ | |
with: | |
environment: production | |
sourcemaps: ./client/dist/spa | |
finalize: false | |
ignore_missing: true | |
ignore_empty: true | |
version: gainstrack@${{ env.SOURCE_VERSION }} | |
- name: Remove Source Maps | |
run: | | |
# Remove all source maps | |
find ./dist/spa -regextype posix-extended -regex '.*.(js|css).map$' -type f -delete | |
# Remove source map references in files | |
sed -i 's/^\/\/# sourceMappingURL=.*$//' $(find ./dist/spa -regextype posix-extended -regex '.*.(js|css)$' -type f) | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build-artifacts | |
path: "./client/dist/spa" | |
deploy_client: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
if: needs.build.outputs.new_release_published == 'true' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: build-artifacts | |
path: "./client/dist/spa" | |
- name: Deploy poc | |
uses: FirebaseExtended/action-hosting-deploy@v0 | |
with: | |
repoToken: '${{ secrets.GITHUB_TOKEN }}' | |
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GAINSTRACK }}' | |
projectId: gainstrack | |
target: poc | |
channelId: live | |
entryPoint: ./client | |
- name: Deploy prod | |
uses: FirebaseExtended/action-hosting-deploy@v0 | |
with: | |
repoToken: '${{ secrets.GITHUB_TOKEN }}' | |
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GAINSTRACK }}' | |
projectId: gainstrack | |
target: prod | |
channelId: live | |
entryPoint: ./client | |
release_backend: | |
name: Build and test backend | |
runs-on: ubuntu-latest | |
needs: [ pre_check ] | |
if: needs.pre_check.outputs.new_release_published == 'true' | |
env: | |
IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v1' | |
- name: Configure Docker | |
run: gcloud auth configure-docker --quiet | |
- name: Build Docker image | |
run: docker build . --file fast.Dockerfile -t $IMAGE_NAME | |
- name: Push Docker image | |
run: docker push $IMAGE_NAME | |
deploy_backend: | |
name: Deploy backend | |
runs-on: ubuntu-latest | |
needs: [ release_backend ] | |
strategy: | |
matrix: | |
server: [ "quotes", "appserver" ] | |
steps: | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v1' | |
- name: Release ${{ matrix.server }} server | |
run: |- | |
gcloud run deploy ${{ matrix.server }} \ | |
--region asia-northeast1 \ | |
--image gcr.io/gainstrack/gainstrack \ | |
--platform managed \ | |
--allow-unauthenticated \ | |
--project gainstrack | |