diff --git a/.github/workflows/create_release_branch.yaml b/.github/workflows/create_release_branch.yaml index 5bdc142b..ef970379 100644 --- a/.github/workflows/create_release_branch.yaml +++ b/.github/workflows/create_release_branch.yaml @@ -1,8 +1,10 @@ name: Create Release Branch + on: schedule: # Run every Friday at 11:30 AM UTC (5:00 PM IST) - cron: '30 11 * * FRI' + jobs: create-release-branch: runs-on: ubuntu-latest @@ -11,10 +13,12 @@ jobs: uses: actions/checkout@v3 with: ref: master + - name: Get Release Branch Name run: | echo "release_branch=xero_api_release_$(date +%Y_%m_%d)" >> $GITHUB_ENV echo "last_release_branch=xero_api_release_$(date -d 'last friday' +%Y_%m_%d)" >> $GITHUB_ENV + - name: Check if release branch exists run: | if git ls-remote --exit-code --heads origin ${{env.release_branch}}; then @@ -22,15 +26,18 @@ jobs: else echo "branch_exists=false" >> $GITHUB_ENV fi + - name: Create release branch if: ${{env.branch_exists == 'false'}} run: | git checkout -b ${{env.release_branch}} git push origin ${{env.release_branch}} echo "message=Branch `${{env.release_branch}}` created successfully." >> $GITHUB_ENV + - name: Branch already exists if: ${{env.branch_exists == 'true'}} run: echo "message=Branch `${{env.release_branch}}` already exists." >> $GITHUB_ENV + - name: Send message on Slack uses: archive/github-actions-slack@v2.0.1 id: notify diff --git a/.github/workflows/hulk_deployment.yaml b/.github/workflows/hulk_deployment.yaml index ffadb669..1c86b678 100644 --- a/.github/workflows/hulk_deployment.yaml +++ b/.github/workflows/hulk_deployment.yaml @@ -1,15 +1,17 @@ name: Deploy to Hulk on: - create: - branches: - - 'xero_api_release_*' push: branches: - 'xero_api_release_*' + workflow_run: + workflows: ["Create Release Branch"] + types: + - completed jobs: hulk_deploy: + name: Hulk Release Pipeline runs-on: ubuntu-latest environment: Staging steps: @@ -17,7 +19,27 @@ jobs: 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=xero_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 + if: ${{ success() }} uses: fylein/docker-release-action@master id: generate-and-push-tag env: @@ -25,6 +47,11 @@ jobs: DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} IMAGE_NAME: fyle_xero-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