This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
fix: Update cicd #6
Workflow file for this run
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: Deploy | |
on: | |
push: | |
branches: [main] | |
tags: | |
- "v*" | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
id-token: write | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
flags: "" | |
steps: | |
- name: Not tags | |
if: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
run: echo "flags=--snapshot" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# ${{ github.token }} is scoped to the current repositor | |
token: ${{ secrets.GH_PAT }} | |
submodules: true | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ">=1.22.3" | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
id: cache-go | |
with: | |
path: | | |
vendor | |
go.sum | |
key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install dependencies | |
if: steps.cache-go.outputs.cache-hit != 'true' | |
run: go get . | |
- name: Build | |
run: make build | |
- name: Run GoReleaser | |
timeout-minutes: 60 | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
version: latest | |
args: release --clean ${{ env.flags }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# - uses: actions/upload-artifact@v4 | |
# id: artifact-upload-step | |
# with: | |
# name: bypanel | |
# path: | | |
# dist/checksums.txt | |
# dist/*amd64.tar.gz | |
# - name: Output artifact ID | |
# run: echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}' | |
- name: Scp file via ssh to server | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
source: "dist/*-linux-amd64.tar.gz,dist/*-linux-arm64.tar.gz" | |
target: "/tmp/" | |
- name: Executing remote ssh commands | |
# env: | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
# envs: | |
script: | | |
cd /tmp/dist/ || exit | |
ls -t bypctl-*-linux-amd64.tar.gz | tail -n +2 | xargs rm -f | |
tar -zxvf bypctl-*-linux-amd64.tar.gz | |
cd bypctl-*-linux-amd64 | |
\mv bypctl /data/webroot/mirrors/bypanel/bypctl-linux-amd64 | |
cd /data/webroot/mirrors/bypanel | |
sed -i "s@.*bypctl-linux-amd64@$(md5sum bypctl-linux-amd64)@" /data/webroot/mirrors/md5sum.txt | |
cd /tmp/dist/ || exit | |
ls -t bypctl-*-linux-arm64.tar.gz | tail -n +2 | xargs rm -f | |
tar -zxvf bypctl-*-linux-arm64.tar.gz | |
cd bypctl-*-linux-arm64 | |
\mv bypctl /data/webroot/mirrors/bypanel/bypctl-linux-arm64 | |
cd /data/webroot/mirrors/bypanel | |
sed -i "s@.*bypctl-linux-arm64@$(md5sum bypctl-linux-arm64)@" /data/webroot/mirrors/md5sum.txt | |
chown -R 1000:1000 /data/webroot/mirrors/bypanel | |
rm -rf /tmp/dist |