Skip to content

Commit

Permalink
Fix Hulk deployment (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh authored Jun 13, 2024
1 parent 2ad1683 commit d06b3cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/create_release_branch.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,26 +13,31 @@ 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
echo "branch_exists=true" >> $GITHUB_ENV
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/[email protected]
id: notify
Expand Down
33 changes: 30 additions & 3 deletions .github/workflows/hulk_deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
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:
- 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=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:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
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
Expand Down

0 comments on commit d06b3cc

Please sign in to comment.