This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (102 loc) · 3.97 KB
/
main.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
---
name: Main
on:
push:
branches:
- 'release/**'
- 'master'
- 'stg'
pull_request:
paths-ignore:
- '.github/**'
jobs:
node-tests-and-build:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Ensure yarn is installed on self-hosted
run: npm install -g yarn
- name: Install dependencies
run: yarn
- name: Lint
run: yarn lint
- name: Run tests
run: yarn test
- name: Build
run: yarn build
docker-release:
runs-on: self-hosted
needs:
- node-tests-and-build
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/stg' || startsWith(github.ref, 'refs/heads/release') || github.ref == 'refs/heads/wip/mockup'
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get branch name, git commit hash and current time in secs
id: vars
shell: bash
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-' )" >> $GITHUB_OUTPUT
echo "GIT_HASH_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "DATE_IN_SECS=$(date +%s)" >> $GITHUB_OUTPUT
- name: Push to ghcr.io (main, static)
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/master'
with:
context: .
file: ./Dockerfile.static
platforms: linux/amd64
push: true
build-args: |
COMMIT_SHA=${{ steps.vars.outputs.GIT_HASH_SHORT }}
VOCDONI_ENVIRONMENT=dev
ETH_NETWORK_ID=goerli
tags: |
ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.vars.outputs.BRANCH_NAME }}-static
ghcr.io/vocdoni/${{ github.event.repository.name }}:commit-${{ steps.vars.outputs.GIT_HASH_SHORT }}
ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.vars.outputs.BRANCH_NAME }}-static-${{ steps.vars.outputs.DATE_IN_SECS }}
- name: Push to ghcr.io (stg, static)
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/stg'
with:
context: .
file: ./Dockerfile.static
platforms: linux/amd64
push: true
build-args: |
COMMIT_SHA=${{ steps.vars.outputs.GIT_HASH_SHORT }}
VOCDONI_ENVIRONMENT=stg
ETH_NETWORK_ID=goerli
tags: |
ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.vars.outputs.BRANCH_NAME }}
ghcr.io/vocdoni/${{ github.event.repository.name }}:commit-${{ steps.vars.outputs.GIT_HASH_SHORT }}
ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.vars.outputs.BRANCH_NAME }}-static-${{ steps.vars.outputs.DATE_IN_SECS }}
- name: Push to ghcr.io (prod, static)
uses: docker/build-push-action@v5
if: startsWith(github.ref, 'refs/heads/release')
with:
context: .
file: ./Dockerfile.static
platforms: linux/amd64
push: true
build-args: |
COMMIT_SHA=${{ steps.vars.outputs.GIT_HASH_SHORT }}
VOCDONI_ENVIRONMENT=prod
ETH_NETWORK_ID=xdai
tags: |
ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.vars.outputs.BRANCH_NAME }}
ghcr.io/vocdoni/${{ github.event.repository.name }}:commit-${{ steps.vars.outputs.GIT_HASH_SHORT }}
ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.vars.outputs.BRANCH_NAME }}-static-${{ steps.vars.outputs.DATE_IN_SECS }}