-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (60 loc) · 1.93 KB
/
build.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
name: Docker Build and Push
on:
push:
branches:
- main
env:
IMAGE_NAME: doctolib-appointment-finder
jobs:
run-tests:
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14' # specify your node version
- name: Install dependencies
run: yarn install # or npm install
- name: Run tests
run: yarn test # or npm run test
docker-build-and-push:
needs: run-tests
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version
id: pkg
run: echo ::set-output name=version::$(node -p "require('./package.json').version")
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.pkg.outputs.version }}, ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- name: Get commit messages
id: commit-messages
run: |
echo 'COMMIT_MESSAGES<<EOF' >> $GITHUB_ENV
git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h - %s" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create a new GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
tag_name: v${{ steps.pkg.outputs.version }}
release_name: Release v${{ steps.pkg.outputs.version }}
body: ${{ env.COMMIT_MESSAGES }}
draft: false
prerelease: false