-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (120 loc) · 4.46 KB
/
update-test-data.yml
File metadata and controls
141 lines (120 loc) · 4.46 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Update test data from samples
on:
schedule:
- cron: '46 4 * * *' # daily at 04:46 UTC
workflow_dispatch: {}
concurrency: test_data_update
env:
BUILDERS_FILEPATH: "builders.json"
jobs:
build:
name: Create PR to sync test data with the samples
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
- name: ${{ env.BUILDERS_FILEPATH }} exists
id: builder_file_exists
run: |
if [ ! -f ${{ env.BUILDERS_FILEPATH }} ]; then
echo "${{ env.BUILDERS_FILEPATH }} does not exist, skipping"
echo "exists=false" >> $GITHUB_OUTPUT
else
echo "exists=true" >> $GITHUB_OUTPUT
fi
- name: Checkout paketo-buildpacks samples
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
uses: actions/checkout@v6
with:
repository: paketo-buildpacks/samples
path: samples
- name: Checkout Branch
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main
with:
branch: automation/testdata/update
- name: Run the sync action
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
run: |
builders=$(jq -c '.builders.[]' ${{ env.BUILDERS_FILEPATH }})
for builder in $builders; do
test_data=$(echo $builder | jq -c '.test_data // []' | jq -c '.[]')
for td in $test_data; do
sample_dir=$(echo $td | jq -r '.sample_dir // empty')
if [ -z "$sample_dir" ]; then
echo "sample_dir can not be empty"
exit 1
fi
sample_dir="samples/${sample_dir}/"
test_dir=$(echo $td | jq -r '.test_dir // empty')
if [ -z "$test_dir" ]; then
echo "test_dir can not be empty"
exit 1
fi
test_dir="${test_dir}/"
echo
echo "syncing from ${sample_dir} to ${test_dir}"
echo
args=(
--recursive
"${sample_dir}"
"${test_dir}"
--delete
)
if [[ -f "${test_dir}/.syncignore" ]]; then
args+=(
--exclude=".syncignore"
--exclude-from="${test_dir}/.syncignore"
)
fi
rsync ${args[*]}
echo
echo "sync complete"
echo
done
done
- name: Cleanup
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
run: rm -rf samples
- name: Commit
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
id: commit
uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main
with:
message: "Updating test data from samples"
pathspec: "."
keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }}
key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }}
- name: Push Branch
if: ${{ steps.commit.outputs.commit_sha != '' }}
uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main
with:
branch: automation/testdata/update
- name: Open Pull Request
if: ${{ steps.commit.outputs.commit_sha != '' }}
uses: paketo-buildpacks/github-config/actions/pull-request/open@main
with:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
title: "Updates test data from samples"
branch: automation/testdata/update
label: "semver:patch"
failure:
name: Alert on Failure
runs-on: ubuntu-24.04
needs: [build]
if: ${{ always() && needs.build.result == 'failure' }}
steps:
- name: File Failure Alert Issue
uses: paketo-buildpacks/github-config/actions/issue/file@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{ github.repository }}
label: "failure:update-github-config"
comment_if_exists: true
issue_title: "Failure: Update GitHub config workflow"
issue_body: |
Update GitHub config workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
comment_body: |
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}