-
Notifications
You must be signed in to change notification settings - Fork 12
125 lines (105 loc) · 4.35 KB
/
Copy pathbuild-push.yml
File metadata and controls
125 lines (105 loc) · 4.35 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
118
119
120
121
122
123
124
125
name: Build && Push
# Controls when the action will run
on:
push:
branches:
- develop
- staging
env:
NODE_VERSION: 22.x
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# List of jobs
build:
# The type of virtual machine that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v6
- id: extract_branch
uses: swapActions/get-branch-name@v1
- name: Create backend image tags
id: meta-backend
uses: docker/metadata-action@v6
with:
images: ghcr.io/userofficeproject/user-office-backend
flavor: latest=true # adds :latest tag to outputs.tags
tags: | # adds :<sha> tag to outputs.tags
type=sha,format=long,prefix=
type=raw,value=${{ steps.extract_branch.outputs.branch }}
- name: Create frontend image tags
id: meta-frontend
uses: docker/metadata-action@v6
with:
images: ghcr.io/userofficeproject/user-office-frontend
flavor: latest=true # adds :latest tag to outputs.tags
tags: | # adds :<sha> tag to outputs.tags
type=sha,format=long,prefix=
type=raw,value=${{ steps.extract_branch.outputs.branch }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Node.js dependencies
run: npm ci
- name: Set environment variables
run: cp apps/frontend/example.development.env apps/frontend/.env
- name: Generate SDK
run: npm run generate:sdk
- name: Build and push backend
uses: docker/build-push-action@v7
with:
context: ./
platforms: linux/amd64,linux/arm64/v8
file: ./apps/backend/Dockerfile
push: true
tags: ${{ steps.meta-backend.outputs.tags }}
- name: Build and push frontend
uses: docker/build-push-action@v7
with:
context: ./
platforms: linux/amd64,linux/arm64/v8
file: ./apps/frontend/Dockerfile
push: true
tags: ${{ steps.meta-frontend.outputs.tags }}
- name: Trigger pipeline
if: ${{ steps.extract_branch.outputs.branch == 'staging' }} # Only trigger pipeline for staging branch
uses: swapActions/trigger-swap-deployment@v1
with:
repository: ${{ github.event.repository.name }}
environment: ${{ steps.extract_branch.outputs.branch }}
gh-trigger-url: ${{ secrets.GITLAB_TRIGGER_URL }}
gh-token: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
image-tag: ${{ github.sha }}
- name: Trigger deployment updates at STFC
if: ${{ steps.extract_branch.outputs.branch == 'develop' }} # Only trigger Jenkins for develop branch
run: |
curl -k -l -u ${{ secrets.STFC_CI_TRIGGER_USERNAME }}:${{ secrets.STFC_CI_TRIGGER_TOKEN }} "${{ secrets.STFC_CI_TRIGGER_BASE_URL }}/Dev_Deploy_UopCore.LatestImage/build?token=${{ secrets.STFC_CI_TRIGGER_URL_TOKEN }}"
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.AUTOPRFLOW_APP_ID }}
private-key: ${{ secrets.AUTOPRFLOW_APP_PRIVATE_KEY }}
repositories: user-office-scheduler
- name: Trigger user-office-scheduler's generate-sdk workflow
if: ${{ steps.extract_branch.outputs.branch == 'develop' }}
run: |
curl -X POST \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.APP_TOKEN }}" \
-d '{"event_type": "generate-sdk"}' \
https://api.github.com/repos/UserOfficeProject/user-office-scheduler/dispatches
env:
APP_TOKEN: ${{ steps.app-token.outputs.token }}