Skip to content

Commit

Permalink
ci: create pipeline for aws and vultr (#2)
Browse files Browse the repository at this point in the history
* ci: build and deployment to vultr

* ci: remove openfaas/faas-cli:latest-root

* ci: add needs build in deploy

* ci: add working-directory

* ci: checkout das-infra-stack-vultr

* ci: pull template deploy

* ci: add aws build and deployment

* ci: missing job keyword

* ci: add aws bucket s3 path

* ci: s3 zip path

* ci: update-function-code zip path

* ci: update-function-code zip key

* ci: update-function-code publish

* ci: add missing aws region

* ci: add versioning workflow
  • Loading branch information
levisingularity authored Nov 6, 2023
1 parent 375b994 commit 85b893d
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
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 }}

0 comments on commit 85b893d

Please sign in to comment.