Skip to content

Commit 9f6be81

Browse files
committed
Updating github-config
1 parent 612f1fc commit 9f6be81

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Update test data from samples
2+
3+
on:
4+
schedule:
5+
- cron: '47 8 * * *' # daily at 08:46 UTC
6+
workflow_dispatch: {}
7+
8+
concurrency: test_data_update
9+
10+
env:
11+
BUILDERS_FILEPATH: "builders.json"
12+
13+
jobs:
14+
build:
15+
name: Create PR to sync test data with the samples
16+
runs-on: ubuntu-24.04
17+
steps:
18+
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
with:
22+
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
23+
24+
- name: ${{ env.BUILDERS_FILEPATH }} exists
25+
id: builder_file_exists
26+
run: |
27+
if [ ! -f ${{ env.BUILDERS_FILEPATH }} ]; then
28+
echo "${{ env.BUILDERS_FILEPATH }} does not exist, skipping"
29+
echo "exists=false" >> $GITHUB_OUTPUT
30+
else
31+
echo "exists=true" >> $GITHUB_OUTPUT
32+
fi
33+
34+
- name: Checkout paketo-buildpacks samples
35+
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
36+
uses: actions/checkout@v5
37+
with:
38+
repository: paketo-buildpacks/samples
39+
path: samples
40+
41+
- name: Checkout Branch
42+
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
43+
uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main
44+
with:
45+
branch: automation/testdata/update
46+
47+
- name: Run the sync action
48+
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
49+
run: |
50+
builders=$(jq -c '.builders.[]' ${{ env.BUILDERS_FILEPATH }})
51+
for builder in $builders; do
52+
test_data=$(echo $builder | jq -c '.test_data // []' | jq -c '.[]')
53+
for td in $test_data; do
54+
sample_dir=$(echo $td | jq -r '.sample_dir // empty')
55+
if [ -z "$sample_dir" ]; then
56+
echo "sample_dir can not be empty"
57+
exit 1
58+
fi
59+
60+
test_dir=$(echo $td | jq -r '.test_dir // empty')
61+
if [ -z "$test_dir" ]; then
62+
echo "test_dir can not be empty"
63+
exit 1
64+
fi
65+
66+
echo
67+
echo "syncing $sample_dir to $test_dir"
68+
echo
69+
70+
args=()
71+
args+=("-vr" "--delete" "samples/$sample_dir/" "$test_dir/")
72+
73+
rsync ${args[*]}
74+
75+
echo
76+
echo "sync complete"
77+
echo
78+
done
79+
done
80+
81+
- name: Cleanup
82+
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
83+
run: rm -rf samples
84+
85+
- name: Commit
86+
if: ${{ steps.builder_file_exists.outputs.exists == 'true' }}
87+
id: commit
88+
uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main
89+
with:
90+
message: "Updating test data from samples"
91+
pathspec: "."
92+
keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }}
93+
key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }}
94+
95+
- name: Push Branch
96+
if: ${{ steps.commit.outputs.commit_sha != '' }}
97+
uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main
98+
with:
99+
branch: automation/testdata/update
100+
101+
- name: Open Pull Request
102+
if: ${{ steps.commit.outputs.commit_sha != '' }}
103+
uses: paketo-buildpacks/github-config/actions/pull-request/open@main
104+
with:
105+
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
106+
title: "Updates test data from samples"
107+
branch: automation/testdata/update
108+
label: "semver:patch"
109+
110+
failure:
111+
name: Alert on Failure
112+
runs-on: ubuntu-24.04
113+
needs: [build]
114+
if: ${{ always() && needs.build.result == 'failure' }}
115+
steps:
116+
- name: File Failure Alert Issue
117+
uses: paketo-buildpacks/github-config/actions/issue/file@main
118+
with:
119+
token: ${{ secrets.GITHUB_TOKEN }}
120+
repo: ${{ github.repository }}
121+
label: "failure:update-github-config"
122+
comment_if_exists: true
123+
issue_title: "Failure: Update GitHub config workflow"
124+
issue_body: |
125+
Update GitHub config workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
126+
comment_body: |
127+
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

0 commit comments

Comments
 (0)