This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
72 lines (64 loc) · 2.04 KB
/
backend.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
name: Build and Push Explorer Backend Docker Image
on:
push:
branches:
- production-backend
- goerli-backend
- sepolia-backend
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
branch_name: ${{ steps.extract_branch.outputs.branch }}
steps:
- name: Extract branch name
id: extract_branch
run: echo "::set-output name=branch::${GITHUB_REF##*/}"
_build-backend:
runs-on: ubuntu-latest
environment: docker
env:
DOCKER_IMAGE: hopprotocol/explorer-backend
defaults:
run:
working-directory: .
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build application Docker image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
build-args: GIT_REV=${{ github.sha }}
tags: app
load: true
push: false
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push Explorer Backend Docker image to Docker Hub
run: |
BRANCH=${GITHUB_REF##*/}
BRANCH=$(echo $BRANCH | sed 's/\//-/g' | sed 's/-backend//g')
docker tag app $DOCKER_IMAGE:${{ github.sha }}
docker tag app $DOCKER_IMAGE:$BRANCH
docker push $DOCKER_IMAGE:${{ github.sha }}
docker push $DOCKER_IMAGE:$BRANCH
if [ "$BRANCH" == "production" ]; then
docker tag app $DOCKER_IMAGE:latest
docker push $DOCKER_IMAGE:latest
fi
build-backend:
needs: [prepare, _build-backend]
name: Send Backend Status Notification Webhook Request
uses: ./.github/workflows/status_notify.yml
with:
environment: ${{ needs.prepare.outputs.branch_name }}
secrets:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}