-
Notifications
You must be signed in to change notification settings - Fork 7
83 lines (69 loc) · 2.84 KB
/
client_update.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
name: Trigger Client Update
on:
push:
branches:
- 'main'
paths:
- 'server/api/tumdev/campus_backend.proto'
workflow_dispatch:
jobs:
deploy:
runs-on: macos-latest
steps:
- name: Fetch Changes
uses: actions/checkout@v4
with:
fetch-depth: 0 # Checkout everything to get access to the tags
ref: main
repository: TUM-Dev/Campus-Backend
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Dart
uses: dart-lang/setup-dart@v1
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Needed Information
run: |
echo "LATEST_TAG=$(git describe --tags --always --abbrev=0)" >> $GITHUB_ENV
echo "REPOSITORY=TUM-Dev/Campus-Flutter" >> $GITHUB_ENV
echo "FOLDER=bin/\$REPOSITORY" >> $GITHUB_ENV
echo "BRANCH_NAME=chore/update-protos-to-\$LATEST_TAG" >> $GITHUB_ENV
- name: Clone Repository
run: git clone --depth=1 --branch=main https://runner:${{ secrets.CAMPUS_FLUTTER_TOKEN }}@github.com/${{ env.REPOSITORY }} ${{ env.FOLDER }}
- name: Update Proto Files
run: |
cd ${{ env.FOLDER }}
git checkout -b ${{ env.BRANCH_NAME }}
# Update the script files to the latest version.
dart pub global activate protoc_plugin
export PATH="$PATH:$HOME/.pub-cache/bin"
curl -o protos/tumdev/campus_backend.proto https://raw.githubusercontent.com/TUM-Dev/Campus-Backend/main/server/api/tumdev/campus_backend.proto
protoc --dart_out=grpc:lib/base/networking/apis -I./protos google/protobuf/timestamp.proto google/protobuf/empty.proto protos/tumdev/campus_backend.proto
- name: Commit Changes
id: commit
run: |
# Commit the changes and push the feature branch to origin
cd ${{ env.FOLDER }}
git add .
git commit -m "chore: update scripts to ${{ env.LATEST_TAG }}"
git push origin ${{ env.BRANCH_NAME }}
continue-on-error: true
- name: Create Pull Request
if: steps.commit.outcome == 'success'
run: |
# Store the PAT in a file that can be accessed by the
# GitHub CLI.
cd ${{ env.FOLDER }}
echo "${{ secrets.CAMPUS_FLUTTER_TOKEN }}" > token.txt
# Authorize GitHub CLI for the current repository and
# create a pull-requests containing the updates.
gh auth login --with-token < token.txt
gh pr create \
--body "" \
--title "Chore: Update Protos to ${{ env.LATEST_TAG }}" \
--head "${{ env.BRANCH_NAME }}" \
--base "main"
- name: Error Message
if: steps.commit.outcome != 'success'
run: echo "No Changes made to Proto Files!"