-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (85 loc) · 2.93 KB
/
docker.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
name: Docker
# This will run when:
# - when new code is pushed to main/develop to push the tags
# latest and develop
# - when a pull request is created and updated to make sure the
# Dockerfile is still valid.
# To be able to push to dockerhub, this execpts the following
# secrets to be set in the project:
# - NPM_TOKEN : NPM auth token for accessing private chemaxon NPM registry
# - DOCKERHUB_USERNAME : username that can push to the org
# - DOCKERHUB_PASSWORD : password asscoaited with the username
on:
push:
branches:
- main
- develop
pull_request:
# Trigger the workflow on release activity
release:
# Only use the types keyword to narrow down the activity types that will trigger your workflow.
types:
- published
- edited
- created
# Certain actions will only run when this is the main repo.
env:
MAIN_REPO: moleculemaker/ChemScraper-frontend
DOCKERHUB_ORG: moleculemaker
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
- name: Authenticate with private NPM package
run: |
echo "//hub.chemaxon.com/artifactory/api/npm/npm/:_auth=${{ secrets.NPM_TOKEN }}" > $HOME/.npmrc
echo "npmrc_path=$HOME/.npmrc" >> "$GITHUB_ENV"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
moleculemaker/ChemScraper-frontend
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=staging,enable=true
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image (production)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args:
configuration=production
secret-files: |
NPMRC=${{env.npmrc_path}}
- name: Build and push Docker image (staging)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args:
configuration=staging
secret-files: |
NPMRC=${{env.npmrc_path}}