This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
update golang and package version #53
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: Setup Node.js Environment | |
uses: actions/setup-node@v3.3.0 | |
with: | |
node-version: '18' | |
- name: Angular Install | |
working-directory: ./angular | |
run: npm install | |
- name: Angular Build | |
working-directory: ./angular | |
run: npm run build | |
- name: Setup Go Environment | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Go Get | |
run: go get -v | |
# - name: Go Test | |
# run: go test -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: | | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config | |
echo ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
echo ${{ secrets.SSH_KEY_BASE64 }} | base64 -d >> ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa ~/.ssh/config ~/.ssh/known_hosts | |
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 }}" |