-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (71 loc) · 3.07 KB
/
create-ros2-package.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
name: create-ros2-package
on:
workflow_dispatch:
inputs:
package-name:
description: "Name of the ROS 2 package to create"
required: true
type: string
maintainer-email:
description: "Email of the maintainer"
required: true
type: string
maintainer-name:
description: "Name of the maintainer"
required: true
type: string
jobs:
create-package:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v4
- name: Create ROS 2 package
run: |
if [ -d ${{ inputs.package-name }} ]; then
echo "Package ${{ inputs.package-name }} already exists."
exit 1
fi
mkdir ${{ inputs.package-name }} && cd ${{ inputs.package-name }}
if [[ "${{ inputs.package-name }}" != *_msgs ]]; then
mkdir src && touch src/.gitkeep
mkdir include/${{ inputs.package-name }} && touch include/${{ inputs.package-name }}/.gitkeep
mkdir launch && touch launch/.gitkeep
cp ../.template-package/.CMakeLists.txt ./CMakeLists.txt
cp ../.template-package/.package.xml ./package.xml
else
mkdir msg && touch msg/.gitkeep
cp ../.template-interface-package/.CMakeLists.txt ./CMakeLists.txt
cp ../.template-interface-package/.package.xml ./package.xml
fi
sed 's/__PACKAGE_NAME__/${{ inputs.package-name }}/g' ./CMakeLists.txt > "./CMakeLists.txt.tmp"
mv "./CMakeLists.txt.tmp" "./CMakeLists.txt"
sed -e 's/__PACKAGE_NAME__/${{ inputs.package-name }}/g' -e 's/__MAINTAINER_EMAIL__/${{ inputs.maintainer-email }}/g' -e 's/__MAINTAINER_NAME__/${{ inputs.maintainer-name }}/g' ./package.xml > "./package.xml.tmp"
mv "./package.xml.tmp" "./package.xml"
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
base: ${{ github.event.repository.default_branch }}
branch: create-package-${{ inputs.package-name }}
title: "feat: create ${{ inputs.package-name }} package"
commit-message: "feat: create ${{ inputs.package-name }} package"
body: "Create ${{ inputs.package-name }} package."
signoff: true
delete-branch: true
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pr.outputs.pull-request-url }}"
- name: Enable auto-merge
if: ${{ steps.create-pr.outputs.pull-request-operation == 'created' }}
run: gh pr merge --squash --auto "${{ steps.create-pr.outputs.pull-request-number }}"
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}