-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: 'Cleanup Pull Request' | ||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
cleanup-pr: | ||
name: "Cleanup Pull Request" | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
permissions: | ||
contents: read | ||
packages: write | ||
actions: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Kubernetes login | ||
uses: azure/k8s-set-context@v4 | ||
with: | ||
method: kubeconfig | ||
kubeconfig: ${{ secrets.KUBE_CONFIG }} | ||
|
||
- name: Delete Helm Chart | ||
run: | | ||
helm delete project-website-pr-${{ github.event.number }} --namespace project-website-pr-${{ github.event.number }} | ||
- name: Delete Namespace | ||
if: always() | ||
run: | | ||
kubectl delete namespace project-website-pr-${{ github.event.number }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: "Deploy Pull Request" | ||
on: | ||
pull_request: | ||
types: [labeled] | ||
|
||
jobs: | ||
deploy_pr: | ||
name: "Deploy Pull Request" | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.label.name == 'deploy' }} | ||
permissions: | ||
contents: read | ||
packages: write | ||
actions: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: set lower case owner name | ||
run: | | ||
echo "REPO_LC=${REPO,,}" >>${GITHUB_ENV} | ||
env: | ||
REPO: "${{ github.repository }}" | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./.docker/Dockerfile.dev | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ghcr.io/${{ env.REPO_LC }}-dev:pr-${{ github.event.number }} | ||
|
||
- name: "Setup yq" | ||
uses: dcarbone/[email protected] | ||
with: | ||
version: "v4.42.1" | ||
force: true | ||
|
||
- name: Change values in on-pr.yaml | ||
run: | | ||
yq -i ' | ||
.ingress.hosts[0].name = "pr-${{ github.event.number }}.website.dev.green-ecolution.de" | | ||
.deployment.image.tag = "pr-${{ github.event.number }}" | | ||
.deployment.name = "project-website-pr-${{ github.event.number }}" | | ||
.deployment.namespace = "project-website-pr-${{ github.event.number }}" | ||
' ./k8s/values/develop.yaml | ||
- name: Kubernetes login | ||
uses: azure/k8s-set-context@v4 | ||
with: | ||
method: kubeconfig | ||
kubeconfig: ${{ secrets.KUBE_CONFIG }} | ||
|
||
- name: Install Helm Chart | ||
run: | | ||
helm upgrade project-website-pr-${{ github.event.number }} ./k8s \ | ||
--install \ | ||
--namespace project-website-pr-${{ github.event.number }} \ | ||
--create-namespace \ | ||
--wait \ | ||
--values ./k8s/values.yaml \ | ||
--values ./k8s/values/develop.yaml \ | ||
- name: Post comment to Pull Request | ||
uses: thollander/actions-comment-pull-request@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
message: | | ||
Deployment of PR #${{ github.event.number }} successful :rocket: | ||
You can access the deployment at [pr-${{ github.event.number }}.website.dev.green-ecolution.de](https://pr-${{ github.event.number }}.website.dev.green-ecolution.de) to review the changes :eyes: | ||
:warning: **Please note that this deployment is temporary and will be deleted after the PR is closed.** |