diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 90b5079..7cdc2c3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -17,12 +17,13 @@ jobs: build: name: Build static files runs-on: ubuntu-latest + environment: ${{ github.event.inputs.environment || 'staging' }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Configure environment variables - run: echo "${{ secrets.ENV_VARIABLES }}" > .env.local + run: echo "${{ vars.ENV_VARIABLES }}" > .env.local - name: Install pnpm uses: pnpm/action-setup@v4 @@ -52,46 +53,16 @@ jobs: path: dist/ if-no-files-found: error - deploy-staging: - if: github.repository_owner == 'one-zero-eight' && ((github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'staging') || (github.event_name == 'push' && github.ref == 'refs/heads/main')) - name: Deploy to staging server + deploy: + if: github.repository_owner == 'one-zero-eight' && ((github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'production') || (github.event_name == 'push' && github.ref == 'refs/heads/main')) + name: Deploy to server for ${{ github.event.inputs.environment || 'staging' }} needs: build runs-on: self-hosted environment: - name: staging - url: https://pre.innohassle.ru + name: ${{ github.event.inputs.environment || 'staging' }} + url: ${{ vars.DEPLOY_URL }} concurrency: - group: staging - cancel-in-progress: false - steps: - - uses: actions/download-artifact@v4 - with: - name: static-files - path: dist - - - name: Copy files via SSH - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.SSH_HOST }} - username: ${{ secrets.SSH_USERNAME }} - key: ${{ secrets.SSH_KEY }} - fingerprint: ${{ secrets.SSH_FINGERPRINT }} - source: "./dist/*" - target: ${{ secrets.SSH_TARGET_DIR }} - strip_components: 1 - overwrite: true - rm: true - - deploy-production: - if: github.repository_owner == 'one-zero-eight' && (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'production') - name: Deploy to production server - needs: build - runs-on: self-hosted - environment: - name: production - url: https://innohassle.ru - concurrency: - group: production + group: ${{ github.event.inputs.environment || 'staging' }} cancel-in-progress: false steps: - uses: actions/download-artifact@v4