forked from janoside/btc-rpc-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (104 loc) · 3.63 KB
/
Copy pathdocker-image.yml
File metadata and controls
117 lines (104 loc) · 3.63 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
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
name: Build and publish Docker image
on:
pull_request:
paths:
- ".github/workflows/docker-image.yml"
- "app.js"
- "app/**"
- "bin/**"
- "routes/**"
- "public/**"
- "test/**"
- "views/**"
- ".dockerignore"
- "Dockerfile"
- "docker-compose.qbit.yml"
- "npm-shrinkwrap.json"
- "package.json"
push:
branches:
- master
tags:
- "v*"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CI_GCP_PROJECT_ID: analog-stage-198105
CI_GCP_SERVICE_ACCOUNT: gh-actions@analog-stage-198105.iam.gserviceaccount.com
CI_GCP_WORKLOAD_IDENTITY_PROVIDER: projects/453614194473/locations/global/workloadIdentityPools/gh-pool/providers/gh-pool-provider
IMAGE_NAME: gcr.io/analog-stage-198105/luxor-qbit-explorer
jobs:
test-build-publish:
name: Test, build, and publish image
runs-on: tenki-standard-large-plus-16c-32g
timeout-minutes: 30
permissions:
contents: read
id-token: write
steps:
- name: Repository checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Node.js
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: 20
cache: npm
cache-dependency-path: npm-shrinkwrap.json
- name: Install dependencies
run: npm ci
- name: Run tests
run: |
npm test
npm run test:qbit
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Authenticate to GCP
id: auth
if: github.event_name != 'pull_request'
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
token_format: access_token
workload_identity_provider: ${{ env.CI_GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.CI_GCP_SERVICE_ACCOUNT }}
- name: Login to GCR
if: github.event_name != 'pull_request'
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Generate image metadata
id: meta
shell: bash
run: |
short_sha="${GITHUB_SHA:0:7}"
created="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
{
echo "created=${created}"
echo "tags<<EOF"
echo "${IMAGE_NAME}:sha-${short_sha}"
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "${IMAGE_NAME}:latest"
fi
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "${IMAGE_NAME}:${GITHUB_REF_NAME}"
echo "${IMAGE_NAME}:${GITHUB_REF_NAME#v}"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and publish image
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ steps.meta.outputs.created }}