Skip to content

Added features and structure information to README #19

Added features and structure information to README

Added features and structure information to README #19

Workflow file for this run

name: tg-mini-app-template-main-workflow
on: [push, workflow_dispatch]
jobs:
build-api:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: ./api
- name: Build
run: go build -v ./...
build-ui:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up React
run: npm ci
- name: Build
run: npm run build
deploy-ui:
needs: [build-api, build-ui]
if: ${{ github.ref == 'refs/heads/main' }}
env:
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
PROJECT_REGION: ${{ vars.GCP_PROJECT_REGION }}
ARTIFACT_REGISTRY: ${{ vars.GCP_ARTIFACT_REGISTRY }}
SERVICE_ACCOUNT: ${{ vars.GCP_SA_EMAIL }}
UI_SERVICE: ${{ vars.GCP_UI_SERVICE_NAME }}
UI_MAX_INSTANCES: ${{ vars.GCP_UI_SERVICE_MAX_INSTANCES }}
UI_IMAGE: ${{ vars.GCP_PROJECT_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GCP_ARTIFACT_REGISTRY }}/${{ vars.GCP_UI_SERVICE_NAME }}:${{ github.sha }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Authenticate Cloud CLI
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Setup Cloud CLI
uses: google-github-actions/setup-gcloud@v1
- name: Authorize Docker push
run: gcloud auth configure-docker ${{ env.PROJECT_REGION }}-docker.pkg.dev
- name: Build and Push Container
run: |-
docker build -t ${{ env.UI_IMAGE }} . -f prod.dockerfile
docker push ${{ env.UI_IMAGE }}
- name: Deploy UI service to Cloud Run
run: |-
gcloud --quiet run deploy ${{ env.UI_SERVICE }} \
--image=${{ env.UI_IMAGE }} \
--region=${{ env.PROJECT_REGION }} \
--service-account=${{ env.SERVICE_ACCOUNT }} \
--max-instances=${{ env.UI_MAX_INSTANCES }} \
--allow-unauthenticated
deploy-api:
needs: [deploy-ui]
if: ${{ github.ref == 'refs/heads/main' }}
env:
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
PROJECT_REGION: ${{ vars.GCP_PROJECT_REGION }}
ARTIFACT_REGISTRY: ${{ vars.GCP_ARTIFACT_REGISTRY }}
SERVICE_ACCOUNT: ${{ vars.GCP_SA_EMAIL }}
UI_SERVICE: ${{ vars.GCP_UI_SERVICE_NAME }}
API_SERVICE: ${{ vars.GCP_API_SERVICE_NAME }}
API_MAX_INSTANCES: ${{ vars.GCP_API_SERVICE_MAX_INSTANCES }}
API_IMAGE: ${{ vars.GCP_PROJECT_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GCP_ARTIFACT_REGISTRY }}/${{ vars.GCP_API_SERVICE_NAME }}:${{ github.sha }}
TG_TOKEN_SECRET: ${{ vars.GCP_TG_TOKEN_SECRET }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Authenticate Cloud CLI
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Setup Cloud CLI
uses: google-github-actions/setup-gcloud@v1
- name: Authorize Docker push
run: gcloud auth configure-docker ${{ env.PROJECT_REGION }}-docker.pkg.dev
- name: Build and Push Container
run: |-
docker build -t ${{ env.API_IMAGE }} .
docker push ${{ env.API_IMAGE }}
- name: Get UI service URL
run: echo "UI_URL=$(gcloud --quiet run services describe ${{ env.UI_SERVICE }} --platform managed --region ${{ env.PROJECT_REGION }} --format 'value(status.url)')" >> $GITHUB_ENV
- name: Deploy API service to Cloud Run
run: |-
gcloud --quiet run deploy ${{ env.API_SERVICE }} \
--image=${{ env.API_IMAGE }} \
--region=${{ env.PROJECT_REGION }} \
--service-account=${{ env.SERVICE_ACCOUNT }} \
--max-instances=${{ env.API_MAX_INSTANCES }} \
--set-env-vars=TELEGRAM_WEB_APP_URL=${{ env.UI_URL }} \
--set-secrets=TELEGRAM_BOT_TOKEN=${{ env.TG_TOKEN_SECRET }}:latest \
--allow-unauthenticated