This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
Deploy PR-76 to Testing Subdomain #151
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: PR Deployment | |
run-name: Deploy PR-${{ github.event.pull_request.number }} to Testing Subdomain | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- main | |
permissions: | |
contents: read | |
packages: write | |
pull-requests: write | |
jobs: | |
start-comment: | |
uses: ./.github/workflows/comment-pr.yaml | |
if: github.actor != 'renovate[bot]' # Don't run this workflow for renovate bot | |
with: | |
message: | | |
:rocket: Your changes are being deployed to a preview domain. | |
preview-build-push-docker: | |
needs: start-comment | |
uses: ./.github/workflows/build-push-image.yaml | |
with: | |
preview: true | |
preview-deploy: | |
needs: preview-build-push-docker | |
uses: ./.github/workflows/deploy.yaml | |
with: | |
preview: true | |
pr-number: ${{ github.event.pull_request.number }} | |
docker-image: ${{ needs.preview-build-push-docker.outputs.docker-tag }} | |
compose-name: pr_${{ github.event.pull_request.number }} | |
ssh-script: | | |
cd ./preview/pr-${{ github.event.pull_request.number }} | |
cp ~/.env .env | |
mkdir -p ./deployments/keys | |
set_key_value "PR_NUMBER" "${{ github.event.pull_request.number }}" ".env" | |
set_key_value "SERVER_IMAGE" "ghcr.io/wwi21seb-projekt/server-alpha:pr-${{ github.event.pull_request.number }}" ".env" | |
set_key_value "TRAFFIC_RULE" "Host(\`pr-${{ github.event.pull_request.number }}.preview.server-alpha.tech\`)" ".env" | |
set_key_value "MONITORING_TRAFFIC_RULE" "Host(\`monitoring.pr-${{ github.event.pull_request.number }}.preview.server-alpha.tech\`)" ".env" | |
jq --arg pr_number "${{ github.event.pull_request.number }}" ' | |
.panels[] |= | |
if .title == "Server-Alpha Logs" then .targets[0].expr = "{container_name=\"pr_" + $pr_number + "_app_1\"}" | |
elif .title == "Database Logs" then .targets[0].expr = "{container_name=\"pr_" + $pr_number + "_db_1\"}" | |
else . end | |
' deployments/provisioning/dashboards/logs.json > tmp.json && mv tmp.json deployments/provisioning/dashboards/logs.json | |
secrets: inherit | |
success-comment: | |
needs: [start-comment, preview-build-push-docker, preview-deploy] | |
uses: ./.github/workflows/comment-pr.yaml | |
if: ${{ needs.start-comment.result == 'success' && needs.preview-build-push-docker.result == 'success' && needs.preview-deploy.result == 'success'}} | |
with: | |
message: | | |
:white_check_mark: Your changes have been deployed to a preview domain. | |
You can access the preview at https://pr-${{ github.event.pull_request.number }}.preview.server-alpha.tech | |
:warning: Please note that the preview will be deleted once the pull request is closed. | |
failure-comment: | |
needs: [start-comment, preview-build-push-docker, preview-deploy] | |
uses: ./.github/workflows/comment-pr.yaml | |
if: ${{ needs.start-comment.result == 'failure' || needs.preview-build-push-docker.result == 'failure' || needs.preview-deploy.result == 'failure' }} | |
with: | |
message: | | |
:x: Your changes could not be deployed to a preview domain. | |
Please check the logs for more information. |