Workflow run for refs/pull/90/merge #226
Workflow file for this run
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: Obsrv API Service | |
run-name: Workflow run for ${{ github.ref }} | |
on: | |
push: | |
tags: | |
- "*" | |
workflow_dispatch: | |
inputs: | |
aws-deploy: | |
type: boolean | |
required: true | |
default: false | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
verify-tag: | |
runs-on: ubuntu-latest | |
outputs: | |
ALLOWED_TAG: ${{ steps.tag-checker.outputs.TRIGGER_ALLOWED }} | |
steps: | |
- name: Check if tag is one in list of current releases | |
id: tag-checker | |
run: | | |
(echo -n TRIGGER_ALLOWED= && echo 'print("${{ github.ref_name }}".split("_")[0] not in "${{ vars.CURRENT_RELEASE }}")' | python3) >> "$GITHUB_OUTPUT" | |
run-test-cases: | |
needs: verify-tag | |
if: needs.verify-tag.outputs.ALLOWED_TAG == 'True' && github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.10 | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- run: echo $HOME | |
env: | |
FOO: 'BAZ' | |
- run: | | |
echo $FOO | |
echo ${{ env.FOO }} | |
- name: Run test cases | |
shell: bash | |
run: | | |
cd api-service/src/test | |
npm install | |
npm run test | |
build-api-service-image: | |
needs: verify-tag | |
if: needs.verify-tag.outputs.ALLOWED_TAG == 'True' && github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to docker hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build docker image and push | |
uses: docker/build-push-action@v4 | |
with: | |
file: ./api-service/Dockerfile | |
push: true | |
tags: ${{ vars.DOCKERHUB_USERNAME }}/obsrv-api-service:${{ github.ref_name }} | |
build-command-service-image: | |
needs: verify-tag | |
if: needs.verify-tag.outputs.ALLOWED_TAG == 'True' && github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to docker hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build docker image and push | |
uses: docker/build-push-action@v2 | |
with: | |
file: ./command-service/Dockerfile | |
push: true | |
tags: ${{ vars.DOCKERHUB_USERNAME }}/flink-command-service:${{ github.ref_name }} | |
aws-deploy: | |
needs: [verify-tag, build-api-service-image, build-command-service-image] | |
if: needs.verify-tag.outputs.ALLOWED_TAG == 'True' && github.event.inputs.aws-deploy == 'true' | |
runs-on: ubuntu-latest | |
environment: aws-dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Terragrunt | |
uses: autero1/action-terragrunt@v1.1.0 | |
with: | |
terragrunt_version: v0.45.8 | |
- name: Terragrunt installation | |
run: terragrunt --version | |
- name: Clone the terraform deployment repo | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ vars.DEPLOY_REPO }} | |
path: deploy | |
ref: ${{ vars.DEPLOY_REPO_REF }} | |
- name: Fetch and update kubeconfig file | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
run: | | |
aws eks --region ${{ vars.AWS_REGION }} update-kubeconfig --name ${{ vars.KUBERNETES_CLUSTER_NAME }} | |
- name: Run terraform init and apply | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
AWS_TERRAFORM_BACKEND_BUCKET_NAME: ${{ vars.AWS_TERRAFORM_BACKEND_BUCKET_NAME }} | |
AWS_TERRAFORM_BACKEND_BUCKET_REGION: ${{ vars.AWS_TERRAFORM_BACKEND_BUCKET_REGION }} | |
KUBE_CONFIG_PATH: ~/.kube/config | |
run: | | |
cd deploy/terraform/aws | |
terragrunt init | |
terragrunt apply -auto-approve --target=module.dataset_api \ | |
-var dataset_api_container_registry=${{ vars.DOCKERHUB_USERNAME }} \ | |
-var dataset_api_image_tag=${{ github.ref_name }} | |
azure-deploy: | |
needs: [verify-tag, build-api-service-image, build-command-service-image] | |
if: needs.verify-tag.outputs.ALLOWED_TAG == 'True' && vars.CLOUD_PROVIDER == 'azure' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone the terraform deployment repo | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ vars.DEPLOY_REPO }} | |
path: deploy | |
ref: ${{ vars.DEPLOY_REPO_REF }} | |
- name: Run terraform init and apply | |
env: | |
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
run: | | |
cd deploy/terraform/azure | |
terragrunt init | |
terragrunt apply -auto-approve --target=module.dataset_api \ | |
-var dataset_api_container_registry=${{ secrets.DOCKERHUB_USERNAME }} \ | |
-var dataset_api_image_tag=${{ github.ref_name }} |