Преглед на файлове

Create push_test_server.yml

Signed-off-by: link <a624669980@163.com>
link преди 2 години
родител
ревизия
3d31ad6689
променени са 1 файла, в които са добавени 58 реда и са изтрити 0 реда
  1. 58 0
      .github/workflows/push_test_server.yml

+ 58 - 0
.github/workflows/push_test_server.yml

@@ -0,0 +1,58 @@
+name: Auto Publish Website
+on:
+  push:
+    branches:
+      - main
+permissions:
+  contents: write
+jobs:
+  goreleaser:
+    runs-on: ubuntu-22.04
+    steps:
+      -
+        name: Checkout
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+      - name: isntall git
+        run: sudo apt install --yes git
+      - name: git global
+        run: sudo git config --global --add safe.directory '*'
+      -
+        name: Fetch all tags
+        run: sudo git fetch --force --tags
+      - name: Get version
+        id: get_version
+        # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
+        run: echo "VERSION=$(git describe --abbrev=0 --tags | awk -F- '{print $1}')" >> $GITHUB_ENV
+      - name: show version
+        id: show_version
+        # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
+        run: echo ${{env.VERSION}}
+      -
+        name: Set up Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.19
+      -
+        name: Run GoReleaser
+        uses: goreleaser/goreleaser-action@v2
+        with:
+          # either 'goreleaser' (default) or 'goreleaser-pro'
+          distribution: goreleaser
+          version: latest
+          args: release --rm-dist
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
+          # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
+      - name: install sshpass
+        run: sudo apt install sshpass --yes
+      - name: copy tar to target host
+        shell: bash
+        run: |
+          sshpass -p "${{ secrets.ssh_password }}" scp -r -o StrictHostKeyChecking=no -P ${{ secrets.ssh_port }} ./dist/*.gz root@${{ secrets.ssh_ip }}:/var/www/download
+          echo "ping success"
+      - name: send message
+        run: |
+          curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"CasaOS updated"}}'  https://open.feishu.cn/open-apis/bot/v2/hook/eb8f45c7-9636-4b64-84f2-a66d9aeb9d30