From c4b46f4c8dd8ff69c4dcddbf2872b606533fb80d Mon Sep 17 00:00:00 2001 From: Dhaarani <55541808+DhaaraniCIT@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:58:44 +0530 Subject: [PATCH] hulk deploy yml file creation (#612) --- .github/workflows/hulk_deployment.yml | 83 +++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/hulk_deployment.yml diff --git a/.github/workflows/hulk_deployment.yml b/.github/workflows/hulk_deployment.yml new file mode 100644 index 00000000..27dbca33 --- /dev/null +++ b/.github/workflows/hulk_deployment.yml @@ -0,0 +1,83 @@ +name: Deploy to Hulk + +on: + push: + branches: + - 'netsuite_api_release_*' + workflow_run: + workflows: ["Create Release Branch"] + types: + - completed + +jobs: + hulk_deploy: + runs-on: ubuntu-latest + environment: Staging + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Run CI + id: run-ci + run: | + echo "Running ci" + + - name: Get Release branch name if workflow_run + if: github.event_name == 'workflow_run' + run: | + echo "release_branch=netsuite_api_release_$(date +%Y_%m_%d)" >> $GITHUB_ENV + + - name: Checkout to Release branch if workflow_run + uses: actions/checkout@v4 + if: github.event_name == 'workflow_run' + with: + ref: ${{env.release_branch}} + + - name: Verify current branch + run: git branch --show-current + + - name: Push to dockerhub + uses: fylein/docker-release-action@master + id: generate-and-push-tag + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + IMAGE_NAME: fyle_netsuite-api + + - name: Print docker image version + run: | + NEW_TAG=${{ steps.generate-and-push-tag.outputs.new_tag }} + echo "docker image version: $NEW_TAG" + + - name: Install kustomize + run: | + curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash + sudo mv kustomize /usr/local/bin/ + + - name: Clone another repository + uses: actions/checkout@v2 + with: + repository: ${{ vars.STAGING_DEPLOY_REPO }} + ref: master + path: ${{ vars.STAGING_DEPLOY_REPO }} + persist-credentials: false + token: ${{ secrets.DEPLOY_GIT_ACCESS_TOKEN }} + + - name: Update Image Tag + run: | + NEW_TAG=${{ steps.generate-and-push-tag.outputs.new_tag }} + cd ${{ vars.STAGING_DEPLOY_REPO }}/${{ vars.STAGING_DEPLOY_DIR }}/hulk/integrations + kustomize edit set image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/fyle_netsuite-api=docker.io/${{ secrets.DOCKERHUB_USERNAME }}/fyle_netsuite-api:$NEW_TAG + + - name: Commit and push changes + run: | + NEW_TAG=${{ steps.generate-and-push-tag.outputs.new_tag }} + cd ${{ vars.STAGING_DEPLOY_REPO }} + git config --global user.email "integrations@fylehq.com" + git config --global user.name "GitHub Actions" + git add . + git commit -m "Deployed fyle_netsuite-api:$NEW_TAG to hulk" + git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_GIT_ACCESS_TOKEN }}@github.com/${{ vars.STAGING_DEPLOY_REPO }} + git pull origin master + git push origin master \ No newline at end of file