Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy a test website per pull request instead of beta.habrasanta.org #19

Merged
merged 7 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions .github/workflows/beta.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: Build the dev branch and deploy it to beta.habrasanta.org
name: Build the pull request and deploy it on habrasanta.org
on:
workflow_run:
workflows:
- Test each and every commit
branches:
- dev
types:
- completed
pull_request:
permissions:
contents: read
deployments: write
concurrency:
group: deploy
cancel-in-progress: false
group: pull-request-${{ github.event.number }}-deployment
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
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!
- name: Deploy to ${{ env.DOMAIN }}
run: |
mkdir ~/.ssh
echo "${{vars.SSH_KNOWN_HOSTS}}" > ~/.ssh/known_hosts
echo "${{ vars.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
eval `ssh-agent`
echo "${{secrets.SSH_PRIVATE_KEY}}" | ssh-add -
rsync --recursive --verbose dist/ [email protected]:/var/www/beta.habrasanta.org
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 }}
25 changes: 15 additions & 10 deletions .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
name: Build the main branch and deploy it to habra-adm.ru
on:
workflow_run:
workflows:
- Test each and every commit
push:
branches:
- main
types:
- completed
permissions:
contents: read
deployments: write
concurrency:
group: deploy
group: deployment
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: habra-adm.ru
url: https://habra-adm.ru
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm ci
- run: npm run build
env:
NODE_ENV: production
- name: Deploy!
- name: Deploy to habra-adm.ru
run: |
mkdir ~/.ssh
echo "${{vars.SSH_KNOWN_HOSTS}}" > ~/.ssh/known_hosts
echo "${{ vars.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
eval `ssh-agent`
echo "${{secrets.SSH_PRIVATE_KEY}}" | ssh-add -
echo "$SSH_PRIVATE_KEY" | ssh-add -
rsync --recursive --verbose dist/ [email protected]:/var/www/habra-adm.ru
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Check if the URL is accessible
run: curl --fail https://habra-adm.ru
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ By default, the beta backend (https://beta.habrasanta.org) is used.
$ NODE_ENV=production npm run build
```

## Deploying to beta.habrasanta.org
## Deployment

Simply push to `dev`, GitHub will do the rest.
Deployment is completely automated thanks to GitHub Actions.

## Deploying to habra-adm.ru
When a pull request is open, a new website is automatically created at `pull-request-#num.habrasanta.org` are your changes are deployed there.

Merge `dev` to `main`, GitHub will do the rest.
Once the pull request is merged to `main`, it is automatically deployed on https://habra-adm.ru and starts making the users happy.

See also the latest deployments in the sidebar on the right 👉