Deploy the public dir #48
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: Build the pull request and deploy it on habrasanta.org | |
on: | |
pull_request: | |
permissions: | |
contents: read | |
deployments: write | |
concurrency: | |
group: pull-request-${{ github.event.number }}-deployment | |
cancel-in-progress: true | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
environment: | |
# Looks like ${{ env.DOMAIN }} is not allowed in "name" | |
name: pull-request-${{ github.event.number }}.habrasanta.org | |
url: https://${{ env.DOMAIN }} | |
env: | |
DOMAIN: pull-request-${{ github.event.number }}.habrasanta.org | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
- run: npm ci | |
- run: npm run build | |
env: | |
NODE_ENV: production | |
- name: Deploy to ${{ env.DOMAIN }} | |
run: | | |
mkdir ~/.ssh | |
echo "${{ vars.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts | |
eval `ssh-agent` | |
echo "$SSH_PRIVATE_KEY" | ssh-add - | |
rsync --recursive --verbose dist/ [email protected]:/var/www/${{ env.DOMAIN }} | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Check if the URL is accessible | |
run: curl --fail https://${{ env.DOMAIN }} |