-
-
Notifications
You must be signed in to change notification settings - Fork 23
85 lines (75 loc) · 2.21 KB
/
rel-pr-merged.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Cleanup staging. Usually occurs after a pr is merged or closed.
name: Teardown staging deployment
env:
AMBUDA_VERSION: v0.1
on:
# push:
# branches:
# - 'main'
# tags:
# - 'v*'
pull_request:
branches:
- 'release'
types:
- closed
jobs:
pr_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
environment: staging
permissions:
packages: write
contents: read
steps:
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,event=pr,value=v0.1-pr${{ github.event.pull_request.number }}
type=ref,event=branch,value=v0.1-{{branch}}-{{sha}}
type=raw,event=push,value=v0.1-{{branch}}-{{sha}}
- name: Extract Image tag
shell: bash
run: echo "${AMBUDA_IMAGE}" >> image-name
id: extract_image_details
env:
AMBUDA_IMAGE: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- uses: actions/upload-artifact@v3
with:
name: image-name
path: image-name
stop_staging:
name: Stop staging deploy
needs: pr_merged
runs-on: [self-hosted, staging, linux]
environment: staging
steps:
- uses: actions/download-artifact@v3
id: image-name
with:
name: image-name
- name: extract_image_details
shell: bash
run: |
echo "AMBUDA_IMAGE=`cat image-name`" >> $GITHUB_ENV
cat image-name
- name: Stop the deploy job
id: stagingdeploy
run: bash /home/ambuda-devbot/bin/ambuda-runner -i ${{ env.AMBUDA_IMAGE }} -x
commeent_pr_merged:
# This job only runs on PR open or reopen
name: PR comment
needs: stop_staging
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Create comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: 'Your pull request has been successfully merged.'
reactions: '+1'