Skip to content

Merge pull request #69 from Fam-Story/feat/66-realtime-chat #72

Merge pull request #69 from Fam-Story/feat/66-realtime-chat

Merge pull request #69 from Fam-Story/feat/66-realtime-chat #72

Workflow file for this run

name: Node.js CI/CD
on:
push:
branches: [ "main", "develop" ]
paths-ignore:
- 'k8s/**'
jobs:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 18.x
- name: Install modules & Build
run: |
npm ci
npm run build --if-present
- name: Run test
run: |
npm test
- name: Docker login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_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 }}
CD:
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: Fam-Story/fam-Story_Backend
ref: develop
token: ${{ secrets.ACCESS_TOKEN }}
path: fam-Story_Backend
- name: Update Kubernetes resources
run: |
cd fam-Story_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 fam-Story_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