-
-
Notifications
You must be signed in to change notification settings - Fork 387
88 lines (88 loc) · 3.94 KB
/
release-please.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
name: 🚀 Adding the commit to the next release
on:
push:
branches:
- main
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- id: release
uses: google-github-actions/[email protected]
with:
# We can't use GITHUB_TOKEN here because, github actions can't trigger actions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
# So this is a personal access token
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
release-type: simple
pull-request-title-pattern: "chore${scope}: 🚀 Open Food Facts Backend - Product Opener - Release${component} ${version}."
changelog-types: |
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"taxonomy","section":"Taxonomy","hidden":false},
{"type":"l10n","section":"Translations","hidden":false},
{"type":"style","section":"Technical","hidden":false},
{"type":"docs","section":"Technical","hidden":false},
{"type":"test","section":"Technical","hidden":false}
]
- name: Wait for frontend container build workflow
# only if a new release was created
if: ${{ steps.release.outputs.release_created }}
id: wait-build
uses: tomchv/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: build (frontend)
ref: ${{ github.event.pull_request.head.sha || github.sha }}
intervalSeconds: 10
timeoutSeconds: 600 # 10m
- name: Get a stripped version of tag_name
# only if a new release was created
if: ${{ steps.release.outputs.release_created }}
run: |
TAG_NAME="${{ steps.release.outputs.tag_name }}"
# remove eventual initial v
STRIPPED_TAG_NAME=${TAG_NAME/v/}
echo "TAG_NAME=$STRIPPED_TAG_NAME" >> $GITHUB_ENV
- name: Get JS dist files to add to the release
# only if a new release was created
if: ${{ steps.release.outputs.release_created }}
id: create-frontend-dist-tar
run : |
# directory to put files in
mkdir -p /tmp/frontend-dist
# download docker image corresponding to the tag
image_name=ghcr.io/${{ github.repository }}/frontend:${{ env.TAG_NAME }}
# pull image, eventually waiting for it to be available in ghcr.io
waited=0
while ! (docker pull $image_name); do
sleep 30
waited=$((waited+30))
# timeout after 6 minutes
if [[ $waited -gt 360 ]]; then
echo "Timeout waiting for image $image_name"
# Abort the job
exit 1
fi
done
# extract the dist files, we create a temporary docker container and use docker cp
id=$(docker create $image_name)
docker cp -a $id:/opt/product-opener/html/css/dist/ /tmp/frontend-dist/css/
docker cp -a $id:/opt/product-opener/html/images/icons/dist/ /tmp/frontend-dist/icons/
docker cp -a $id:/opt/product-opener/html/images/attributes/dist/ /tmp/frontend-dist/attributes/
docker cp -a $id:/opt/product-opener/html/js/dist/ /tmp/frontend-dist/js/
docker rm -v $id
# make a tar
tar czf /tmp/frontend-dist.tgz -C /tmp/frontend-dist .
- name: Add the dist tar to the release
# only if a new release was created
if: ${{ steps.release.outputs.release_created }}
id: add-frontend-dist-to-release
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /tmp/frontend-dist.tgz
asset_name: frontend-dist.tgz
tag: ${{ steps.release.outputs.tag_name }}
overwrite: true