From aabe88e441c001ae1b4738a763063db2326d2410 Mon Sep 17 00:00:00 2001 From: Artur Sudnik-Hrynkiewicz Date: Mon, 16 Oct 2023 10:41:01 +0200 Subject: [PATCH] chore: adding `Build and deploy VC-API` workflow (#186) --- .github/workflows/deploy-vc-api.yml | 77 +++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/deploy-vc-api.yml diff --git a/.github/workflows/deploy-vc-api.yml b/.github/workflows/deploy-vc-api.yml new file mode 100644 index 00000000..ced6f636 --- /dev/null +++ b/.github/workflows/deploy-vc-api.yml @@ -0,0 +1,77 @@ +name: Build and deploy VC-API + +on: [workflow_dispatch] + +jobs: + cancel-previous: + name: 'Cancel Previous Runs' + runs-on: ubuntu-latest + timeout-minutes: 3 + steps: + - uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + install-build-and-push: + runs-on: ubuntu-latest + needs: [cancel-previous] + steps: + - name: Check out vc-api-owf + run: | + git clone https://github.com/energywebfoundation/vc-api-owf + + - name: Configure AWS credentials IDC + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr-ssi + uses: aws-actions/amazon-ecr-login@v2 + + - name: Getting GIT SHA value + id: get-git-sha + working-directory: ./vc-api-owf + run: echo "git-sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + - name: Build Docker image + working-directory: ./vc-api-owf + env: + ECR_REGISTRY: ${{ steps.login-ecr-ssi.outputs.registry }} + AWS_ECR_REPOSITORY_SSI: ${{ secrets.DEV_ECR_REPOSITORY }} + GIT_SHA: ${{ steps.get-git-sha.outputs.git-sha }} + run: | + docker build \ + -t $ECR_REGISTRY/$AWS_ECR_REPOSITORY_SSI:$GIT_SHA \ + -f apps/vc-api/Dockerfile . + + - name: Push Docker image + working-directory: ./vc-api-owf + env: + ECR_REGISTRY: ${{ steps.login-ecr-ssi.outputs.registry }} + AWS_ECR_REPOSITORY_SSI: ${{ secrets.DEV_ECR_REPOSITORY }} + GIT_SHA: ${{ steps.get-git-sha.outputs.git-sha }} + run: | + docker push \ + $ECR_REGISTRY/$AWS_ECR_REPOSITORY_SSI:$GIT_SHA + + - name: Logout of Amazon ECR + if: always() + run: docker logout ${{ steps.login-ecr-idc.outputs.registry }} + + + - name: ARGO CD LOGIN + uses: clowdhaus/argo-cd-action/@v1.9.0 + id: argocd_login_ssi + with: + command: login ${{ secrets.DEV_ARGOCD_URL }} + options: --insecure --password ${{ secrets.DEV_ARGOCD_PASS }} --username ${{ secrets.DEV_ARGOCD_USERNAME }} + + - name: ArgoCD overvrite SSI values.yaml + uses: clowdhaus/argo-cd-action/@v1.9.0 + id: argocd_image_tag_overwrite_ssi + with: + command: app set ssi-wallet + options: -p image.tag=${{ steps.get-git-sha.outputs.git-sha }}