Skip to content

Commit

Permalink
Updated workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
GopalSaraf committed Nov 25, 2024
1 parent e61435d commit fc07173
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 17 deletions.
53 changes: 44 additions & 9 deletions .github/workflows/process-pending-feedbacks-build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
name: Process Pending Feedbacks Build and Push Docker Image
name: Process Pending Feedbacks Build, Push and Deploy to Dev
on:
workflow_dispatch:

permissions:
contents: read
packages: write

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: interviewandhealth
IMAGE_NAME: cronjob/process-pending-feedbacks
IMAGE_TAG: v${{ github.run_number }}
CLUSTER_USERNAME: InterviewAndHealth
CLUSTER_REPOSITORY: Cluster
BRANCH: main
USERNAME: GopalSaraf
ACCESS_TOKEN: ${{ secrets.PERSONEL_TOKEN }}
FILE_PATH: services/cronjobs/process-pending-feedbacks/overlays/development
KEY: newTag
ENVIRONMENT: development

jobs:
build:
name: Build Image and Push to GitHub Container Registry
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: interviewandhealth
IMAGE_NAME: cronjob/process-pending-feedbacks
IMAGE_TAG: v${{ github.run_number }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -36,4 +45,30 @@ jobs:
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
deploy:
name: Deploy to Development
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
shell: bash
run: |
REPOSITORY=https://${{ env.USERNAME }}:${{ env.ACCESS_TOKEN }}@github.com/${{ env.CLUSTER_USERNAME }}/${{ env.CLUSTER_REPOSITORY }}.git
git clone $REPOSITORY --depth 1 --branch ${{ env.BRANCH }} --single-branch .
- name: Update Kustomization File
shell: bash
run: |
sed -i "s/${{ env.KEY }}: .*/${{ env.KEY }}: ${{ env.IMAGE_TAG }}/g" ${{ env.FILE_PATH }}
- name: Commit Changes
shell: bash
run: |
git config user.name "${{ env.USERNAME }}"
git config user.email "${{ env.USERNAME }}@users.noreply.github.com"
git add $FILE_PATH
git commit -m "Update ${{ env.IMAGE_NAME }} image tag to ${{ env.IMAGE_TAG }} in ${{ env.ENVIRONMENT }}"
git pull --rebase
git push
56 changes: 56 additions & 0 deletions .github/workflows/process-pending-feedbacks-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Process Pending Feedbacks Deploy to Production
on:
workflow_dispatch:

env:
GITHUB_USERNAME: interviewandhealth
IMAGE_NAME: cronjob/process-pending-feedbacks
CLUSTER_USERNAME: InterviewAndHealth
CLUSTER_REPOSITORY: Cluster
BRANCH: main
USERNAME: GopalSaraf
ACCESS_TOKEN: ${{ secrets.PERSONEL_TOKEN }}
FILE_PATH: services/cronjobs/process-pending-feedbacks/overlays/production/kustomization.yaml
KEY: newTag
ENVIRONMENT: production

jobs:
update:
name: Deploy to Production
runs-on: ubuntu-latest
steps:
- name: Generate GHCR Token
id: ghcr_token
shell: bash
run: |
GHCR_TOKEN=$(echo ${{ secrets.PERSONEL_TOKEN }} | base64)
echo "GHCR_TOKEN=$GHCR_TOKEN" >> $GITHUB_OUTPUT
- name: Checkout Latest Image Tag
id: checkout
shell: bash
run: |
IMAGE_TAG=$(curl -H "Authorization: Bearer ${{ steps.ghcr_token.outputs.GHCR_TOKEN }}" https://ghcr.io/v2/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}/tags/list | jq -r '.tags | map(select(test("^v[0-9]+$")))[-1]')
# echo "::set-output name=IMAGE_TAG::$IMAGE_TAG"
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Checkout Repository
shell: bash
run: |
REPOSITORY=https://${{ env.USERNAME }}:${{ env.ACCESS_TOKEN }}@github.com/${{ env.CLUSTER_USERNAME }}/${{ env.CLUSTER_REPOSITORY }}.git
git clone $REPOSITORY --depth 1 --branch ${{ env.BRANCH }} --single-branch .
- name: Update Kustomization File
shell: bash
run: |
sed -i "s/${{ env.KEY }}: .*/${{ env.KEY }}: ${{ steps.checkout.outputs.IMAGE_TAG }}/g" ${{ env.FILE_PATH }}
- name: Commit Changes
shell: bash
run: |
git config user.name "${{ env.USERNAME }}"
git config user.email "${{ env.USERNAME }}@users.noreply.github.com"
git add $FILE_PATH
git commit -m "Update ${{ env.IMAGE_NAME }} image tag to ${{ steps.checkout.outputs.IMAGE_TAG }} in ${{ env.ENVIRONMENT }}"
git pull --rebase
git push
51 changes: 43 additions & 8 deletions .github/workflows/rabbitmq-keepalive-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ permissions:
contents: read
packages: write

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: interviewandhealth
IMAGE_NAME: cronjob/rabbitmq-keepalive
IMAGE_TAG: v${{ github.run_number }}
CLUSTER_USERNAME: InterviewAndHealth
CLUSTER_REPOSITORY: Cluster
BRANCH: main
USERNAME: GopalSaraf
ACCESS_TOKEN: ${{ secrets.PERSONEL_TOKEN }}
FILE_PATH: services/cronjobs/rabbitmq-keepalive/overlays/development/kustomization.yaml
KEY: newTag
ENVIRONMENT: development

jobs:
build:
name: Build Image and Push to GitHub Container Registry
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: interviewandhealth
IMAGE_NAME: cronjob/rabbitmq-keepalive
IMAGE_TAG: v${{ github.run_number }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -36,4 +45,30 @@ jobs:
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.DOCKER_REGISTRY }}/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
deploy:
name: Deploy to Development
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
shell: bash
run: |
REPOSITORY=https://${{ env.USERNAME }}:${{ env.ACCESS_TOKEN }}@github.com/${{ env.CLUSTER_USERNAME }}/${{ env.CLUSTER_REPOSITORY }}.git
git clone $REPOSITORY --depth 1 --branch ${{ env.BRANCH }} --single-branch .
- name: Update Kustomization File
shell: bash
run: |
sed -i "s/${{ env.KEY }}: .*/${{ env.KEY }}: ${{ env.IMAGE_TAG }}/g" ${{ env.FILE_PATH }}
- name: Commit Changes
shell: bash
run: |
git config user.name "${{ env.USERNAME }}"
git config user.email "${{ env.USERNAME }}@users.noreply.github.com"
git add $FILE_PATH
git commit -m "Update ${{ env.IMAGE_NAME }} image tag to ${{ env.IMAGE_TAG }} in ${{ env.ENVIRONMENT }}"
git pull --rebase
git push
56 changes: 56 additions & 0 deletions .github/workflows/rabbitmq-keepalive-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: RabbitMQ Keepalive Deploy to Production
on:
workflow_dispatch:

env:
GITHUB_USERNAME: interviewandhealth
IMAGE_NAME: cronjob/rabbitmq-keepalive
CLUSTER_USERNAME: InterviewAndHealth
CLUSTER_REPOSITORY: Cluster
BRANCH: main
USERNAME: GopalSaraf
ACCESS_TOKEN: ${{ secrets.PERSONEL_TOKEN }}
FILE_PATH: services/cronjobs/rabbitmq-keepalive/overlays/production/kustomization.yaml
KEY: newTag
ENVIRONMENT: production

jobs:
update:
name: Deploy to Production
runs-on: ubuntu-latest
steps:
- name: Generate GHCR Token
id: ghcr_token
shell: bash
run: |
GHCR_TOKEN=$(echo ${{ secrets.PERSONEL_TOKEN }} | base64)
echo "GHCR_TOKEN=$GHCR_TOKEN" >> $GITHUB_OUTPUT
- name: Checkout Latest Image Tag
id: checkout
shell: bash
run: |
IMAGE_TAG=$(curl -H "Authorization: Bearer ${{ steps.ghcr_token.outputs.GHCR_TOKEN }}" https://ghcr.io/v2/${{ env.GITHUB_USERNAME }}/${{ env.IMAGE_NAME }}/tags/list | jq -r '.tags | map(select(test("^v[0-9]+$")))[-1]')
# echo "::set-output name=IMAGE_TAG::$IMAGE_TAG"
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Checkout Repository
shell: bash
run: |
REPOSITORY=https://${{ env.USERNAME }}:${{ env.ACCESS_TOKEN }}@github.com/${{ env.CLUSTER_USERNAME }}/${{ env.CLUSTER_REPOSITORY }}.git
git clone $REPOSITORY --depth 1 --branch ${{ env.BRANCH }} --single-branch .
- name: Update Kustomization File
shell: bash
run: |
sed -i "s/${{ env.KEY }}: .*/${{ env.KEY }}: ${{ steps.checkout.outputs.IMAGE_TAG }}/g" ${{ env.FILE_PATH }}
- name: Commit Changes
shell: bash
run: |
git config user.name "${{ env.USERNAME }}"
git config user.email "${{ env.USERNAME }}@users.noreply.github.com"
git add $FILE_PATH
git commit -m "Update ${{ env.IMAGE_NAME }} image tag to ${{ steps.checkout.outputs.IMAGE_TAG }} in ${{ env.ENVIRONMENT }}"
git pull --rebase
git push

0 comments on commit fc07173

Please sign in to comment.