Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: create pipeline for aws and vultr #2

Merged
merged 15 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/aws-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: AWS Build & Deployment

on:
workflow_run:
workflows: ["Versioning"]
types: [requested]
branches:
- master

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
AWS_S3_BUCKET: das.singularitynet.io
AWS_S3_BUCKET_KEY: production
FUNC_NAME: das-serverless-functions

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install function requirements
run: |-
pip3 install awscli
pip3 install -r ./requirements.txt -t .

- name: Download DocumentDB pem
run: wget https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem

- name: Bundle function into a ZIP file
run: zip -r ${{ env.FUNC_NAME }}.zip .

- name: Push function to s3
run: aws s3 cp ./${{ env.FUNC_NAME }}.zip s3://${{ env.AWS_S3_BUCKET }}/${{ env.AWS_S3_BUCKET_KEY }}/${{ env.FUNC_NAME }}.zip

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Update lambda function
run: aws lambda update-function-code --function-name ${{ env.FUNC_NAME }} --s3-bucket ${{ env.AWS_S3_BUCKET }} --s3-key ${{ env.AWS_S3_BUCKET_KEY }}/${{ env.FUNC_NAME }}.zip --publish --region ${{ env.AWS_REGION }}

24 changes: 24 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Versioning

on:
workflow_dispatch:
inputs:
version:
description: "Version"
required: true

jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Create Tag and Release
uses: singnet/das-scripts-pipeline/.github/workflows/action.yml@master
with:
version: ${{ github.event.inputs.version }}
version-strategy: bump-version-from-variable-value
job-image-namespace: trueagi
job-image-version-semver: semantic-versioning
main-branch: master
version-tag-regex-pattern: /^v\d+\.\d+\.\d+$/
version-require-confirmation: "true"
76 changes: 76 additions & 0 deletions .github/workflows/vultr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: Vultr Build & Deployment

on:
workflow_run:
workflows: ["Versioning"]
types: [requested]
branches:
- master

env:
DEPLOYMENT_FILE: das-function.yml

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup OpenFaaS
run: curl -sSL https://cli.openfaas.com | sudo -E sh

- name: Checkout
uses: actions/checkout@v4
with:
path: das-servless-functions

- name: Checkout das-infra-stack-vultr Repository
uses: actions/checkout@v4
with:
repository: singnet/das-infra-stack-vultr
path: das-infra-stack-vultr
ref: master

- name: Pull template
working-directory: ./das-infra-stack-vultr
run: faas-cli template store pull python3

- name: Run shrinkwrap build
working-directory: ./das-infra-stack-vultr
run: faas-cli build -f ${{ env.DEPLOYMENT_FILE }}

- name: Login to DockerHub
if: success()
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push Image to Registry
working-directory: ./das-infra-stack-vultr
run: faas-cli push -f ${{ env.DEPLOYMENT_FILE }}

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Setup OpenFaaS
run: curl -sSL https://cli.openfaas.com | sudo -E sh

- name: Checkout das-infra-stack-vultr Repository
uses: actions/checkout@v4
with:
repository: singnet/das-infra-stack-vultr
path: das-infra-stack-vultr
ref: master

- name: Login to OpenFaaS Gateway
working-directory: ./das-infra-stack-vultr
run: faas-cli login -p ${{ secrets.OPENFAAS_GATEWAY_PASSWD }} -g ${{ secrets.OPENFAAS_GATEWAY }}

- name: Pull template
working-directory: ./das-infra-stack-vultr
run: faas-cli template store pull python3

- name: Deploy the function
working-directory: ./das-infra-stack-vultr
run: faas-cli deploy -f ${{ env.DEPLOYMENT_FILE }}