diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a4101c5..fd57499 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,39 +1,41 @@ name: Deploy + +concurrency: + group: deploy-${{ github.ref }} + cancel-in-progress: true + on: - schedule: - - cron: "*/30 * * * *" - push: - branches: - - "main" - workflow_dispatch: + push: + branches: + - 'main' jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: oven-sh/setup-bun@v2 - - run: bun install - - name: Setup SSH Key - uses: webfactory/ssh-agent@v0.9.1 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - run: git clone ${{ vars.ARTICLES_REPOSITORY }} articles - - run: bun run build - - uses: actions/upload-artifact@v7 - with: - name: production-files - path: ./dist - deploy: - name: Deploy - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v8 - with: - name: production-files - path: ./dist - - run: tar -czC dist -f dist.tar.gz . - - run: | - curl -v -X PUT -H 'X-Token: ${{ secrets.STAPLER_TOKEN }}' -H 'X-Host-Only: ${{ vars.TARGET_HOST }}' -H 'X-SPA: index.html' --data-binary "@dist.tar.gz" ${{ vars.STAPLER_TARGET }} + build: + runs-on: ubuntu-latest + steps: + - uses: https://github.com/oven-sh/setup-bun@v2 + with: + bun-version: latest + - uses: actions/checkout@v6 + - run: bun ci + - run: bun run build + - uses: actions/upload-artifact@v3 + with: + name: production-files + path: dist/ + + deploy: + runs-on: ubuntu-latest + needs: build + if: ${{ vars.STAPLER_TARGET != '' }} + steps: + - uses: actions/download-artifact@v3 + with: + name: production-files + path: ./dist + - run: tar -czC dist -f dist.tar.gz . + - run: | + curl -s -X PUT --data-binary "@dist.tar.gz" \ + -H 'X-Token: ${{ secrets.STAPLER_TOKEN }}' \ + ${{ vars.STAPLER_CURL_ARGS }} \ + ${{ vars.STAPLER_TARGET }}