-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbuild_and_deploy_docusaurus.yml
More file actions
83 lines (75 loc) · 2.62 KB
/
Copy pathbuild_and_deploy_docusaurus.yml
File metadata and controls
83 lines (75 loc) · 2.62 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
name: Build and deploy docusaurus
on:
push:
branches:
- main
paths:
- 'docs/**'
pull_request:
branches:
- main
release:
types:
- published
workflow_call:
workflow_dispatch:
jobs:
build-and-push:
name: Build and push from ${{ github.ref_name }}/${{ github.sha }}
runs-on: ubuntu-latest
env:
APP_IMAGE_NAME: ghcr.io/etalab-ia/opengatellm/docs
IMAGE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || 'latest' }}
outputs:
commit_title: ${{ steps.get_head_commit_title.outputs.title }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: get_head_commit_title
run: echo "title=$(git log --format=%B -n 1 HEAD | head -n 1)" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push docusaurus
uses: docker/build-push-action@v6
with:
context: ./docs/
file: ./docs/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.APP_IMAGE_NAME }}:${{ env.IMAGE_TAG }}
target: serve
cache-from: type=registry,ref=${{ env.APP_IMAGE_NAME }}:cache
cache-to: type=registry,ref=${{ env.APP_IMAGE_NAME }}:cache,mode=max
build-args: |
DOCUSAURUS_BASE_URL=/documentation/
ALBERT_API_URL=https://albert.api.dev.etalab.gouv.fr
outputs: type=registry
provenance: false
deploy-prod:
if: github.event_name == 'push'
name: Deploy from ${{ github.ref_name }}/${{ github.sha }}
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Trigger dev deployment
run: |
RESPONSE="$(curl --request POST \
--form token=${{ secrets.GITLAB_CI_TOKEN }} \
--form ref=main \
--form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ needs.build-and-push.outputs.commit_title }}' \
--form 'variables[docker_image_tag]=latest' \
--form 'variables[application_to_deploy]=albert-api-docusaurus' \
--form 'variables[deployment_environment]=prod' \
'https://gitlab.com/api/v4/projects/58117805/trigger/pipeline')"
if echo "$RESPONSE" | grep -q '"status":"created"'; then
echo $RESPONSE
else
echo $RESPONSE
exit 1
fi