-
Notifications
You must be signed in to change notification settings - Fork 2
57 lines (48 loc) · 1.73 KB
/
close-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: 'Remove deployment'
on:
pull_request:
types: [ closed ]
jobs:
cleanup:
name: 'Remove Docker Compose deployment'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: 'Set variables for PR'
env:
PR: ${{ github.event.pull_request.number }}
run: |
echo "VERSION_TAG=pr-${PR}" >> $GITHUB_ENV
- uses: arwynfr/actions-docker-context@v2
with:
docker_host: ${{ secrets.DEPLOY_DOCKER_HOST }}
context_name: 'dev-server'
ssh_cert: ${{ secrets.DEPLOY_DOCKER_HOST_SSH_CERT }}
ssh_key: ${{ secrets.DEPLOY_DOCKER_HOST_SSH_KEY }}
use_context: true
- name: 'Add known hosts'
run: |
DEPLOY_DOCKER_HOST=${{ secrets.DEPLOY_DOCKER_HOST }}
ssh-keyscan -H ${DEPLOY_DOCKER_HOST##*@} > $HOME/.ssh/known_hosts
- uses: actions/checkout@v4
with:
repository: B3Partners/tailormap-viewer
path: tailormap-viewer
sparse-checkout: |
docker-compose*.yml
sparse-checkout-cone-mode: false
- name: 'Remove pull request deployment and image'
env:
COMPOSE_FILE: docker-compose.yml:docker-compose.traefik.yml:ci/docker-compose.pr.yml
COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME}-pr-${PR}
VERSION: ${{ env.VERSION_TAG }}
run: |
cd tailormap-viewer
docker compose config
docker compose down --rmi all --remove-orphans
- name: 'Remove GitHub deployment and environment'
if: ${{ always() }}
uses: strumwolf/delete-deployment-environment@v2
with:
token: "${{ secrets.GITHUB_TOKEN }}"
environment: "${{ env.VERSION_TAG }}"