-
Notifications
You must be signed in to change notification settings - Fork 6
51 lines (43 loc) · 2.13 KB
/
feature-based-delete.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
name: Delete feature
on:
pull_request:
types:
- closed
jobs:
delete:
if: github.event.pull_request.merged == true
name: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
- uses: mdecoleman/pr-branch-name@2.0.0
id: vars
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch name
shell: bash
run: echo "name=$(echo ${{ steps.vars.outputs.branch }} | sed 's/^deploy\///')" >> $GITHUB_ENV
id: extract_branch
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN_STAGING }}
- name: remove previous feature
continue-on-error: true
run: |
doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_STAGING }}
NAME=${{ env.name }} && sed -i 's|<BRANCH>|'${NAME}'|' $GITHUB_WORKSPACE/deployment/deploy/all.yaml
NAME=${{ env.name }} && sed -i 's|<BRANCH>|'${NAME}'|' $GITHUB_WORKSPACE/deployment/deploy/deployment.yaml
kubectl delete -f $GITHUB_WORKSPACE/deployment/deploy/
- name: Get CF A record ID
continue-on-error: true
shell: bash
run: echo "record=$(echo $(curl -X GET "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/dns_records?type=A&name=${{ env.name }}-subid.subsocial.network&content=174.138.105.155&proxied=true&page=1&per_page=100&order=type&direction=desc&match=all" -H "X-Auth-Email:${{ secrets.CF_MAIL }}" -H "Authorization:Bearer ${{ secrets.CF_TOKEN }}" -H "Content-Type:application/json" | jq . | jq -c '.result[]' | jq -r .id) )" >> $GITHUB_ENV
id: cf
- name: delete CF A record
continue-on-error: true
run: curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/dns_records/${{ env.record }}" -H "X-Auth-Email:${{ secrets.CF_MAIL }}" -H "Authorization:Bearer ${{ secrets.CF_TOKEN }}" -H "Content-Type:application/json"
- name: final task
if: always()
run: echo "finished successfully"