Skip to content

chore(k8s): restructure Kubernetes configurations for DigitalOcean and GKE, add TLS support and update resources #44

chore(k8s): restructure Kubernetes configurations for DigitalOcean and GKE, add TLS support and update resources

chore(k8s): restructure Kubernetes configurations for DigitalOcean and GKE, add TLS support and update resources #44

Workflow file for this run

name: CI - master
on:
pull_request:
types: [closed]
branches:
- "master"
permissions:
contents: read
packages: write
actions: write
env:
GITHUB_ACTOR: ${{ github.actor }}
APP_VERSION: ${{ vars.APP_VERSION }}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
IMAGE_REPO: ${{ github.repository_owner }}
jobs:
# unit-test:
# name: Run Unit Test
# runs-on: ubuntu-latest
# strategy:
# fail-fast: true # 一個 job fail,其他 job 會被取消
# matrix:
# node-version: [18, 20, 22]
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# - name: Install dependencies
# run: npm run install:all
# - name: Run frontend tests
# run: cd frontend && npm run test --if-present
# - name: Run backend tests
# run: cd backend && npm run test --if-present
# - name: Send Slack notification on failure
# if: failure()
# run: |
# curl -X POST -H 'Content-type: application/json' \
# --data '{
# "text": ":x: Unit tests failed in `${{ github.repository }}` on branch `${{ github.ref_name }}` by `${{ github.actor }}`.\nCheck run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# }' \
# ${{ secrets.SLACK_WEBHOOK_URL }}
bump-version:
name: Bump Version and Update GitHub Variable
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'build')
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
# needs: unit-test # 等 unit-test 成功才執行
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Bump patch version
id: bump
uses: actions-ecosystem/action-bump-semver@v1
with:
current_version: ${{ env.APP_VERSION }}
level: patch
- name: Install GitHub CLI
run: sudo apt-get update && sudo apt-get install -y gh
- name: Update GitHub variable
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/actions/variables/APP_VERSION \
-f name='APP_VERSION' \
-f value="${{ steps.bump.outputs.new_version }}"
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
build-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'build')
needs:
# - unit-test # 等 unit-test 成功才執行
- bump-version # 等 bump-version 成功才執行
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert repository name to lowercase
id: repo-lower
run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo-lower.outputs.repo }}
tags: |
type=raw,value=${{ needs.bump-version.outputs.new_version }}
type=raw,value=latest
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=Notion Chart Generator
org.opencontainers.image.version=${{ needs.bump-version.outputs.new_version }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max