-
Notifications
You must be signed in to change notification settings - Fork 3
72 lines (62 loc) · 2.17 KB
/
Copy pathdeploy-dev.yaml
File metadata and controls
72 lines (62 loc) · 2.17 KB
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
name: Deploy DEV
on:
push:
branches: [develop]
workflow_dispatch:
concurrency:
group: deploy-dev
cancel-in-progress: false
env:
DOCKER_TAGS: 21gifts/api:beta
permissions:
contents: read
jobs:
build-and-deploy:
name: Build and deploy to DEV
runs-on: ubuntu-24.04-arm
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.DOCKER_TAGS }}
platforms: linux/arm64
cache-from: type=registry,ref=21gifts/api:buildcache
cache-to: type=registry,ref=21gifts/api:buildcache,mode=max
- name: Notify infrastructure to pull :beta
env:
GH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
DISPATCH_REPO: ${{ secrets.DISPATCH_REPO }}
run: |
set -euo pipefail
if [ -z "${GH_TOKEN}" ] || [ -z "${DISPATCH_REPO}" ]; then
echo "::error::DISPATCH_TOKEN or DISPATCH_REPO unset — cannot deploy this image"
exit 1
fi
# Five-second slack so a run created just before this clock is still
# eligible; the wait script still matches image+tag+sha.
dispatched_at="$(date -u -d '5 seconds ago' +%Y-%m-%dT%H:%M:%SZ)"
echo "DISPATCHED_AT=${dispatched_at}" >> "$GITHUB_ENV"
gh api "repos/${DISPATCH_REPO}/dispatches" \
-f event_type=image-published \
-f "client_payload[image]=21gifts/api" \
-f "client_payload[tag]=beta" \
-f "client_payload[sha]=${GITHUB_SHA}"
- name: Wait for infrastructure deploy
env:
GH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
DISPATCH_REPO: ${{ secrets.DISPATCH_REPO }}
IMAGE: 21gifts/api
TAG: beta
run: bash .github/scripts/wait-for-image-published.sh