fix: rm loading temporately #121
This file contains hidden or 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: Docker Image CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| DEPLOY_NAME: 'network-monitor' | |
| IMAGE_REPO: 'baimeow/network_monitor' | |
| IMAGE_BASE: 'registry.cn-shanghai.aliyuncs.com' | |
| jobs: | |
| build: | |
| if: github.repository == 'BaiMeow/NetworkMonitor' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache-dependency-path: 'frontend/package.json' | |
| cache: 'pnpm' | |
| - name: Install dependencies and build | |
| run: | | |
| cd frontend | |
| pnpm install | |
| pnpm run build | |
| - name: Gen tag | |
| id: gen-tag | |
| run: echo "tag=$(date +%s)" >> $GITHUB_OUTPUT | |
| - name: Setup Golang | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'backend/go.mod' | |
| cache-dependency-path: 'backend/go.sum' | |
| - name: Build | |
| run: | | |
| cd backend | |
| go build -o main | |
| - name: Build the Docker image | |
| run: | | |
| docker build . -f Dockerfile.actions --tag ${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}:${{ steps.gen-tag.outputs.tag }} | |
| - name: Push the Docker image | |
| timeout-minutes: 3 | |
| run: | | |
| docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ env.IMAGE_BASE }} | |
| docker push ${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}:${{ steps.gen-tag.outputs.tag }} | |
| - name: Checkout ArgoCD | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: BaiMeow/argocd | |
| token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT | |
| path: deploy | |
| - name: Update ArgoCD | |
| run: | | |
| cd deploy/${{ env.DEPLOY_NAME }} | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| sed -i "s|^\(\s*image: '${{ env.IMAGE_BASE }}/${{ env.IMAGE_REPO }}:\)[0-9]\+'|\1${{ steps.gen-tag.outputs.tag }}'|" ${{ env.DEPLOY_NAME }}-deployment.yml | |
| git add . | |
| git commit -m "update(${{ env.DEPLOY_NAME }}): image" | |
| git push |