Skip to content

Commit

Permalink
Update github actions (#96)
Browse files Browse the repository at this point in the history
* update github actions

Signed-off-by: SurabhiAngadi <[email protected]>

* remove check-tag action

Signed-off-by: SurabhiAngadi <[email protected]>

* refactor workflow

Signed-off-by: SurabhiAngadi <[email protected]>

---------

Signed-off-by: SurabhiAngadi <[email protected]>
  • Loading branch information
SurabhiAngadi authored Feb 9, 2024
1 parent 5be2f0d commit 518d6b2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 33 deletions.
55 changes: 25 additions & 30 deletions .github/workflows/build_and_deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,66 @@
name: Obsrv api service build and deploy workflow
name: Build and Deploy
run-name: Workflow run for ${{ github.ref }}
on:
push:
tags:
- '*'

- "*"
workflow_dispatch:
inputs:
aws-deploy:
type: boolean
required: true
default: false
jobs:
check-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"
docker-build-api-service:
needs: check-tag
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
build-api-service-image:
runs-on: ubuntu-latest
steps:
- name: Login to docker hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build docker image and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
file: ./api-service/Dockerfile
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/obsrv-api-service:${{ github.ref_name }}

docker-build-command-service:
needs: check-tag
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
build-command-service-image:
runs-on: ubuntu-latest
steps:
- name: Login to docker hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout code
uses: actions/checkout@v4
- name: Build docker image and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
file: ./command-service/Dockerfile
context: ./command-service
platforms: linux/amd64
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/flink-command-service:${{ github.ref_name }}

aws-deploy:
needs: [check-tag, docker-build-api-service, docker-build-command-service]
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
needs: [build-api-service-image, build-command-service-image]
if: github.event.inputs.aws-deploy == 'true'
runs-on: ubuntu-latest
environment: aws-dev
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Terragrunt
uses: autero1/[email protected]
with:
terragrunt_version: v0.45.8
- name: Terragrunt installation
run: terragrunt --version
- name: Clone the terraform deployment repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ vars.DEPLOY_REPO }}
path: deploy
Expand Down Expand Up @@ -97,12 +92,12 @@ jobs:
-var dataset_api_image_tag=${{ github.ref_name }}
azure-deploy:
needs: [check-tag, docker-build-api-service, docker-build-command-service]
if: needs.check-tag.outputs.ALLOWED_TAG == 'True' && vars.CLOUD_PROVIDER == 'azure'
needs: [build-api-service-image, build-command-service-image]
if: vars.CLOUD_PROVIDER == 'azure'
runs-on: ubuntu-latest
steps:
- name: Clone the terraform deployment repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ vars.DEPLOY_REPO }}
path: deploy
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pull Request
run-name: Workflow run for pull request- ${{ github.event.pull_request.title }}
on:
pull_request:
types:
- opened
- synchronize

jobs:
test-cases:
if: 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@v4

- name: Run test cases
run: |
cd api-service
npm install
npm run actions:test
1 change: 1 addition & 0 deletions api-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"start": "ts-node ./src/app.ts",
"test": "source .env.test && nyc mocha ./src/test/*.spec.ts --exit",
"actions:test": "nyc mocha ./src/test/*.spec.ts --exit",
"build": "tsc -P ."
},
"author": "GayathriSrividya",
Expand Down
4 changes: 1 addition & 3 deletions command-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
FROM --platform=linux/amd64 python:3.10-alpine
COPY --from=ubuntu /usr/local/bin /usr/local/bin

RUN apk update && apk add curl jq && curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && chmod +x kubectl && mv kubectl /usr/local/bin/

RUN apk add libcrypto3=3.1.4-r3
RUN apk add libcrypto3=3.1.4-r5
RUN apk upgrade
WORKDIR /app
COPY requirements.txt .
Expand Down

0 comments on commit 518d6b2

Please sign in to comment.