Files
archtika/.github/workflows/deploy.yml
2024-10-27 01:50:05 +02:00

51 lines
1.5 KiB
YAML

name: Deploy to server
on:
workflow_run:
workflows: [ 'Playwright tests' ]
types: [ completed ]
branches: [ devel, main ]
jobs:
environment-check:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }}
outputs:
env_name: ${{ github.event.workflow_run.head_branch == 'devel' && 'qs' || 'prod' }}
steps:
- name: Determine and print environment
run: |
echo "Determining environment..."
echo "Environment name: ${{ github.event.workflow_run.head_branch == 'devel' && 'qs' || 'prod' }}"
deploy:
needs: environment-check
runs-on: ubuntu-latest
environment:
name: ${{ needs.environment-check.outputs.env_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy to demo server
run: |
nix run nixpkgs#nixos-rebuild -- switch \
--flake .#${{ vars.FLAKE_CONFIGURATION_NAME }} \
--fast \
--build-host ${{ vars.SERVER_DEPLOY_USER }}@${{ vars.PUBLIC_SERVER_IP }} \
--target-host ${{ vars.SERVER_DEPLOY_USER }}@${{ vars.PUBLIC_SERVER_IP }} \
--use-remote-sudo