-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (49 loc) · 1.68 KB
/
publish.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
name: Build and Push Docker Image
on:
push:
branches:
- main
env:
CONTAINER_REGISTRY: registry.digitalocean.com
DOCKERFILE_PATH: '**/Dockerfile'
DOCKER_CREDS: dop_v1_7cdb76fb1ff0da0379bf302937aeea27d6dbc82a513de1fb164baeb5dbf13092
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Set IMAGE_REPOSITORY based on branch
id: set_repo
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "IMAGE_REPOSITORY=path-of-terraria/website" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "IMAGE_REPOSITORY=path-of-terraria/main-qa" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Run pnpm install
run: pnpm i
- name: Run pnpm build
run: pnpm run build
- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: https://${{ env.CONTAINER_REGISTRY }}
username: ${{ env.DOCKER_CREDS }}
password: ${{ env.DOCKER_CREDS }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }}
${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:latest