Skip to content

Commit

Permalink
ci: use variables from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Sep 28, 2024
1 parent 3e8e38f commit e6194f3
Showing 1 changed file with 8 additions and 37 deletions.
45 changes: 8 additions & 37 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/[email protected]
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
Expand Down

0 comments on commit e6194f3

Please sign in to comment.