forked from buildlyio/buildly-react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (87 loc) · 2.84 KB
/
prod-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
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
name: Build and Push Docker Image to Prod
on:
push:
branches:
- prod
env:
PROJECT_ID: spry-bricolage-298920
REGION: us
IMAGE_NAME: us-docker.pkg.dev/spry-bricolage-298920/gcr.io/prod/react-ui
jobs:
build:
name: Build and Push image to GCR
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
# auto generate tag from label defined in Dockerfile
- name: Tag version
uses: Klemensas/action-autotag@stable
id: tag_version
with:
GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}"
# Create release notes
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@main
with:
configuration: 'release-changelog-builder-config.json'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
# Create release
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.tagname }}
release_name: Release ${{ steps.tag_version.outputs.tagname }}
body: ${{ steps.build_changelog.outputs.changelog }}
draft: false
prerelease: false
- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCR_JSON_KEY }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
- name: "Use gcloud CLI"
run: "gcloud info"
- name: yarn install, build and test
run: |
yarn install
yarn run build:prod
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
# Build docker image
- name: Build docker image
run: docker build -t $IMAGE_NAME:latest .
# Push docker image to GCR
- name: Push to Google Container Registry
run: docker push $IMAGE_NAME:latest
# Send message on Slack
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'Production Docker Image of buildly-ui pushed to Google Container Registry Successfully'
MSG_MINIMAL: true
# Send email alert
- name: Email Alert
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: Github Actions Build and Push job alert
to: ${{ secrets.RECIPIENT_EMAIL }}
from: ${{ secrets.SENDER_EMAIL }}
body: Production Docker Image of buildly-ui pushed to Google Container Registry Successfully