Compare commits

..

2 commits

Author SHA1 Message Date
jtbx d5fc2adfe1 CI: Post staging URL to PR once (on open event)
All checks were successful
/ build (pull_request) Successful in 38s
/ cleanup-staging (pull_request) Successful in 1s
/ build (push) Successful in 13s
2024-01-28 13:04:48 +01:00
jtbx b1e4e69be2 CI: Auto-remove closed PRs from staging 2024-01-28 13:02:05 +01:00
2 changed files with 21 additions and 7 deletions

View file

@ -1,6 +1,6 @@
on:
pull_request:
pull_request_target:
types:
- closed
jobs:
@ -11,9 +11,13 @@ jobs:
steps:
- name: Pipeline info PR
run: |
echo "PR#${{ github.event.pull_request.number }} ${{ github.event.action }}"
echo "Run triggered by ${{ github.event_name }} (${{ github.event.action }}) on ref ${{ github.ref_name }}"
- name: Deploy - Remove PR from staging
if: github.event.action == 'closed'
- name: Staging Deployment - Prepare keys
run: |
ssh -i deploykey.priv -o 'UserKnownHostsFile ./known_hosts' ccchh-website-deploy@public-web-static-intern.hamburg.ccc.de -t "rm -r /var/www/next.hamburg.ccc.de/pr${{ github.event.pull_request.number }}/"
echo "${{ secrets.SSH_DEPLOY_KEY }}" > deploykey.priv
chmod 400 deploykey.priv
echo "${{ secrets.SSH_KNOWN_HOSTS_FILE }}" > ./known_hosts
- name: Staging Deployment - Remove PR from staging
run: |
ssh -i deploykey.priv -o 'UserKnownHostsFile ./known_hosts' ccchh-website-deploy@public-web-static-intern.hamburg.ccc.de -t "rm -r /var/www/staging.hamburg.ccc.de/pr${{ github.event.pull_request.number }}/"

View file

@ -17,7 +17,7 @@ jobs:
steps:
- name: Pipeline info
run: |
echo "Run triggered by ${{ gitea.event_name }} on ref ${{ github.ref_name }}"
echo "Run triggered by ${{ github.event_name }} (${{ github.event.action }}) on ref ${{ github.ref_name }}"
- name: Install packages
run: |
@ -54,6 +54,16 @@ jobs:
run: |
echo "Deploying to staging.hamburg.ccc.de/pr${{ github.event.pull_request.number }}"
rsync -v -r --delete -e "ssh -i deploykey.priv -o 'UserKnownHostsFile ./known_hosts'" public/ ccchh-website-deploy@public-web-static-intern.hamburg.ccc.de:/var/www/staging.hamburg.ccc.de/pr${{ github.event.pull_request.number }}/
- name: Deploy - Add comment to PR with staging URL
if: github.event_name == 'pull_request' && github.event.action == 'opened'
run: |
curl \
-X POST \
${{ github.event.pull_request.base.repo.url }}/issues/${{ github.event.pull_request.number }}/comments \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
--data '{ "body": "You can view your changes at https://staging.hamburg.ccc.de/pr${{ github.event.pull_request.number }}/" }'
- name: Deploy - Upload to prod
if: github.event_name == 'push' && github.ref_name == 'main'
run: |