From 3bbb0598bc1604877c62472c39a1881ad6f6f72c Mon Sep 17 00:00:00 2001 From: morbalint Date: Sun, 17 Mar 2024 09:51:06 +0100 Subject: [PATCH] ci: add frontend deployment --- .github/workflows/deploy-backend.yml | 2 +- .github/workflows/deploy-frontend.yml | 44 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-frontend.yml diff --git a/.github/workflows/deploy-backend.yml b/.github/workflows/deploy-backend.yml index 7fcd892..7cf6644 100644 --- a/.github/workflows/deploy-backend.yml +++ b/.github/workflows/deploy-backend.yml @@ -1,4 +1,4 @@ -name: Deploy backend beta to production +name: Deploy backend to production on: workflow_dispatch: diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml new file mode 100644 index 0000000..598bc2f --- /dev/null +++ b/.github/workflows/deploy-frontend.yml @@ -0,0 +1,44 @@ +name: Deploy frontend to production + +on: + workflow_dispatch: + inputs: + frontend_image: + description: "Frontend image to deploy" + required: false + type: string + +jobs: + deploy-backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.DEPLOYMENT_KEY }} + - id: get_beta_image + if: ${{ inputs.frontend_image == '' }} + uses: mikefarah/yq@v4 + with: + cmd: yq '.spec.template.spec.containers[0].image' ./kemkas-beta/kemkas-fe-deployment.yaml + - run: | + if [ -n "${{ inputs.frontend_image }}" ]; then + echo "Image from INPUT" + echo "IMAGE=${{ inputs.frontend_image }}" >> $GITHUB_ENV + exit 0; + fi + if [ -n "${{ steps.get_beta_image.outputs.result }}" ]; then + echo "Image from BETA" + echo "IMAGE=${{ steps.get_beta_image.outputs.result }}" >> $GITHUB_ENV + exit 0; + fi + echo "Image NOT SET !!!"; + exit 1; + - run: echo "deployment image will be set to ${{ env.IMAGE }}" + - uses: mikefarah/yq@v4 + with: + cmd: yq -i '.spec.template.spec.containers[0].image = "${{ env.IMAGE }}"' ./kemkas/kemkas-fe-deployment.yaml + - run: | + git config --global user.name "Prod Frontend Deployment Bot" + git config --global user.email "prod-fe-deployment-bot@kemkas.hu" + git commit -a -m "prod deploy ${{ env.IMAGE }}" + git push