Skip to content

Update Diareat-CICD.yml #25

Update Diareat-CICD.yml

Update Diareat-CICD.yml #25

Workflow file for this run

name: Diareat CI/CD
on:
push:
branches: [ "master" ]
paths-ignore:
- 'k8s/**'
permissions:
contents: read
jobs:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
env:
DB_ENDPOINT: ${{ secrets.DB_ENDPOINT }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
with:
arguments: build
- name: Docker login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
logout: true
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- name: Build and push to DockerHub
run: |
docker build -t synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }} .
docker push synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }}
update-manifest:
runs-on: ubuntu-latest
needs: CI
steps:
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- name: Setup Kustomize
uses: imranismail/[email protected]
- name: Checkout kustomize repository
uses: actions/checkout@v3
with:
repository: CAUSOLDOUTMEN/Diareat_backend
ref: master
token: ${{ secrets.ACCESS_TOKEN }}
path: Diareat_backend
- name: Update Kubernetes resources
run: |
cd Diareat_backend/k8s/
kustomize edit set image synoti21/${{ secrets.PROJECT_NAME }}=synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }}
kustomize build .
- name: Commit and push the updated manifest
run: |
cd Diareat_backend
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git commit -am ":construction_worker: chore: Update deployment to ${{ github.sha }}"
git push