-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (118 loc) · 4.82 KB
/
build-publish-staging.yaml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build and Deploy Staging Docker Images
on:
push:
branches:
- main
paths-ignore:
- '**/README.md'
- '**/CONTRIBUTING.md'
- '**/CONFIGURATION.md'
- '**/.devcontainer/**'
- "**/.github/workflows/**"
workflow_dispatch:
jobs:
build-preview:
name: Build Staging Artifacts
environment:
name: preview
runs-on: ubuntu-latest
outputs:
image_version: ${{ steps.build_image_tag.outputs.image_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install NodeJS Dependencies
run: npm install
- name: Get Commit Hash
id: commit_hash
uses: prompt/actions-commit-hash@v3
- name: Get Current Date
id: date
run: echo "today=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Build Image Tag
id: build_image_tag
run: echo "image_version=${{ steps.date.outputs.today }}.${{github.run_number}}.0-${{ steps.commit_hash.outputs.short }}" >> $GITHUB_OUTPUT
- name: Build Container Image Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.REGISTRY }}/${{ vars.REGISTRY_ORG }}/${{ vars.IMG_NAME }}
tags: |
type=raw,value=${{ steps.build_image_tag.outputs.image_version }}
- name: Build App
env:
REACT_APP_VERSION: ${{ steps.build_image_tag.outputs.image_version }}
REACT_APP_DOCS_NEXT_HOST: ${{ vars.DOCS_NEXT_HOST }}
REACT_APP_DOCS_NEXT_ORG: ${{ vars.DOCS_NEXT_ORG }}
REACT_APP_DOCUSAURUS_BASE_URL: ${{ vars.DOCUSAURUS_BASE_URL }}
REACT_APP_TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }}
REACT_APP_TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }}
REACT_APP_TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }}
REACT_APP_TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_SEARCH_KEY }}
UMAMI_WEBSITE_ID: ${{ vars.UMAMI_WEBSITE_ID }}
UMAMI_ANALYTICS_DOMAIN: ${{ vars.UMAMI_ANALYTICS_DOMAIN }}
UMAMI_DATAHOST_URL: ${{ vars.UMAMI_DATAHOST_URL }}
UMAMI_DATA_DOMAIN: ${{ vars.UMAMI_DATA_DOMAINS }}
run: npm run build
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Setup Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Build and Push (Docker Image)
id: docker_build
uses: docker/[email protected]
with:
context: ./
file: ./Dockerfile
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
update-helm-charts:
needs: [build-preview]
environment: preview
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Create GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_KEY }}
- name: Checkout Charts Repo
uses: actions/checkout@v4
with:
repository: "${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}"
token: ${{ steps.app-token.outputs.token }}
- name: Commit Changes
env:
image: ${{ vars.REGISTRY }}/${{ vars.REGISTRY_ORG }}/${{ vars.IMG_NAME }}
tag: ${{ needs.build-preview.outputs.image_version }}
run: |
git config --global user.name 'otcbot'
git config --global user.email '[email protected]'
sed -i 's|^tag: .*|tag: ${{ env.tag }}|' ./charts/docusaurus/values-stg.yaml
sed -i 's|^image: .*|image: ${{ env.image }}|' ./charts/docusaurus/values-stg.yaml
git commit -am "Automatic commit from GitHub Actions triggered by action #${{github.run_number}}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
env:
remote_pr_branch: 'release/staging-${{ needs.build-preview.outputs.image_version }}'
with:
title: ${{ env.remote_pr_branch }}
token: ${{ steps.app-token.outputs.token }}
branch: ${{ env.remote_pr_branch }}