This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
fix bug #69
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: CI/CD | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Angular Install | |
working-directory: ./angular | |
run: npm install | |
- name: Angular Build | |
working-directory: ./angular | |
run: npm run build:ssr | |
- name: Setup Go Environment | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
- name: Go Get | |
run: go get -v | |
- name: Go Build | |
run: go build -o jgo | |
- name: Setup Current Time Environment | |
uses: josStorer/get-current-time@v2.0.2 | |
id: current-time | |
with: | |
format: YYYYMMDDHHmmSS | |
utcOffset: "+08:00" | |
- name: Copy And Replace Secrets | |
run: | | |
sed -i 's/MYSQL_DSN/${{ secrets.MYSQL_DSN }}/g' ./config/config.yaml | |
sed -i 's/MSSQL_DSN/${{ secrets.MSSQL_DSN }}/g' ./config/config.yaml | |
sed -i 's/ORACLE_DSN/${{ secrets.ORACLE_DSN }}/g' ./config/config.yaml | |
sed -i 's/POSTGRESQL_DSN/${{ secrets.POSTGRESQL_DSN }}/g' ./config/config.yaml | |
env: | |
NOW: "${{ steps.current-time.outputs.formattedTime }}" | |
- name: Build Docker image | |
run: docker build . --tag ${{ secrets.HARBOR }}/jgo:${{ env.NOW }} | |
env: | |
NOW: "${{ steps.current-time.outputs.formattedTime }}" | |
- name: Login Harbor | |
run: docker login -u ${{ secrets.HARBOR_USER }} -p ${{ secrets.HARBOR_PWD }} ${{ secrets.HARBOR_URL }} | |
- name: Push Image | |
run: docker push ${{ secrets.HARBOR }}/jgo:${{ env.NOW }} | |
env: | |
NOW: "${{ steps.current-time.outputs.formattedTime }}" | |
- name: Apply Deployment | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd ${{ secrets.WEB_FOLDER }} | |
cp default.yaml deployment.yaml | |
sed -i 's/TAG/${{ env.NOW }}/g' deployment.yaml | |
kubectl apply -f deployment.yaml | |
env: | |
NOW: "${{ steps.current-time.outputs.formattedTime }}" |