-
-
Notifications
You must be signed in to change notification settings - Fork 23
123 lines (106 loc) · 3.75 KB
/
rel-pr-open.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Build release image. Push image to ghcr.io. Deploy on staging environment.
name: Release image build & publish
env:
AMBUDA_VERSION: v0.1
AMBUDA_HOST_IP: 127.0.0.1
AMBUDA_HOST_PORT: 5090
REGISTRY: ghcr.io
on:
workflow_dispatch:
pull_request:
branches:
- 'release'
types: [opened, reopened, synchronize]
jobs:
push_to_registries:
name: Push Ambuda image to GH container registry
runs-on: ubuntu-22.04
environment: staging
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: GH container registry login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ 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 Id
id: image_id
shell: bash
run: |
echo "AMBUDA_IMAGE=${{ env.AMBUDA_IMAGE }}" >> $GITHUB_ENV
echo "${{ env.AMBUDA_IMAGE }}" >> image-name
env:
AMBUDA_IMAGE: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- uses: actions/upload-artifact@v3
with:
name: image-name
path: image-name
- name: Build and push Docker images
id: publish
uses: docker/build-push-action@v4.0.0
with:
context: .
file: build/containers/Dockerfile.final
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Run SQL db setup
id: dbsetup
run: docker compose -f deploy/local/docker-compose-dbsetup.yml up
- name: Run Docker images
id: deploy
run: docker compose -f deploy/local/docker-compose.yml up --detach
env:
AMBUDA_HOST_IP: 0.0.0.0
- name: Check that site is running
run: timeout 2m bash -c "until curl --fail-with-body $AMBUDA_HOST_IP:$AMBUDA_HOST_PORT; do sleep 1; done"
- name: Show logs on fail
if: ${{ failure() }}
run: docker compose -f deploy/local/docker-compose.yml logs
pr_commented:
# This job only runs on PR open or reopen
name: PR comment
needs: push_to_registries
if: ${{ github.event.issue.pull_request.opened || github.event.issue.pull_request.reopened }}
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 is open. Reviewers will review the pullrequest at the earliest.'
reactions: '+1'
deploy_staging:
name: Run staging deploy
needs: push_to_registries
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
echo "AMBUDA_IMAGE_TAG=${AMBUDA_IMAGE#ghcr.io/ambuda-org/ambuda:}" >> $GITHUB_ENV
cat image-name
- name: Start the deploy job
id: stagingdeploy
run: bash /home/ambuda-devbot/bin/ambuda-runner -i ${{ env.AMBUDA_IMAGE }} -s