Skip to content

Add files via upload #76

Add files via upload

Add files via upload #76

name: Baekjoon-Bot CI/CD
on:
push:
branches: [ "main" ]
paths-ignore:
- 'k8s/**'
jobs:
CI:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: "18.x"
- name: Install modules
run: npm ci
- name: Unit test
run: npm test
- 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: boaz-baekjoon/baekjoon-discord-bot
ref: main
token: ${{ secrets.ACCESS_TOKEN }}
path: baekjoon-discord-bot
- name: Update Kubernetes resources
run: |
cd baekjoon-discord-bot/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 baekjoon-discord-bot
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