graduates 문서 작성 #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous integration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
REPO: inje-megabrain/megabrain.kr | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Define container metadata before build | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/inje-megabrain/megabrain.kr | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Setup nodejs | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
cache: npm | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Set up Docker Buildx (Builder instance) | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Github Container Registry for Image Push | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build Image and Push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
target: production | |
platform: linux/amd64 | |
tags: ghcr.io/${{ env.REPO }}:${{ secrets.MAJOR_VERSION }}.${{ secrets.MINOR_VERSION }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
kubernetes-resource-update: | |
name: Kubernetes resource update | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v1 | |
- name: Checkout kustomize repo | |
uses: actions/checkout@v2 | |
with: | |
repository: inje-megabrain/megabrain-infra-apps | |
ref: apps/megabrain-site | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Update Kubernetes resource | |
run: | | |
cd apps/megabrain-site/overlays/dev | |
kustomize edit set image ghcr.io/${{ env.REPO }}:${{ secrets.MAJOR_VERSION }}.${{ secrets.MINOR_VERSION }} | |
cat kustomization.yaml | |
- name: Commit and push changes | |
run: | | |
cd apps/megabrain-site | |
git config --global user.name puleugo | |
git config --global user.email [email protected] | |
git commit -am "Update k8s image" | |
git push -u origin apps/megabrain-site | |
- name: Get Minor version variable in Repository variable | |
run: echo NEW_MINOR_VERSION=$[${{ secrets.MINOR_VERSION }} + 1] >> $GITHUB_ENV | |
- name: Increment Minor version | |
uses: hmanzur/[email protected] | |
with: | |
name: 'MINOR_VERSION' | |
value: ${{ env.NEW_MINOR_VERSION }} | |
repository: ${{ env.REPO }} | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} |