-
Notifications
You must be signed in to change notification settings - Fork 5
137 lines (119 loc) · 4.22 KB
/
sync-common.yml
File metadata and controls
137 lines (119 loc) · 4.22 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
name: Sync common files
on:
workflow_dispatch:
inputs:
test_mode:
description: 'Test mode - only sync to ci-sandbox'
type: boolean
default: false
push:
branches:
- main
paths:
- 'common/**'
- '.github/workflows/sync-common.yml'
- 'scripts/sync-common/**'
# Prevent multiple workflow runs from racing
concurrency: ${{ github.workflow }}
permissions:
contents: read
jobs:
build:
name: Build sync-common tool
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Rust
uses: bootc-dev/actions/setup-rust@main
- name: Build sync-common
run: cargo build --release --manifest-path scripts/sync-common/Cargo.toml
- name: Upload sync-common binary
uses: actions/upload-artifact@v7
with:
name: sync-common
path: scripts/sync-common/target/release/sync-common
retention-days: 1
init:
name: Discover repositories
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
steps:
- name: Generate Actions Token (bootc-dev)
id: token-bootc
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Generate Actions Token (composefs)
id: token-composefs
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: composefs
- name: Discover repositories
id: discover
uses: bootc-dev/actions/discover-repos@main
with:
orgs: '["${{ github.repository_owner }}", "composefs"]'
tokens: '{"${{ github.repository_owner }}": "${{ steps.token-bootc.outputs.token }}", "composefs": "${{ steps.token-composefs.outputs.token }}"}'
test-mode: ${{ github.event.inputs.test_mode || 'false' }}
exclude-self: 'true'
sync:
name: Sync to ${{ matrix.full_name }}
needs: [build, init]
if: needs.init.outputs.matrix != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: Generate Actions Token
id: token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ matrix.owner }}
repositories: ${{ matrix.repo }}
- name: Checkout infra repository
uses: actions/checkout@v6
with:
path: infra
fetch-depth: 0
- name: Checkout target repository
uses: actions/checkout@v6
with:
repository: ${{ matrix.full_name }}
token: ${{ steps.token.outputs.token }}
path: repo
- name: Download sync-common binary
uses: actions/download-artifact@v8
with:
name: sync-common
path: .
- name: Sync common files to repository
run: |
chmod +x sync-common
./sync-common infra repo "${{ github.sha }}"
- name: Open pull request
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.token.outputs.token }}
path: repo
branch: sync-common-files
commit-message: |
Sync common files from infra repository
Synchronized from ${{ github.repository }}@${{ github.sha }}.
title: Sync common files from infra repository
body: |
Created by [GitHub workflow](${{ github.server_url }}/${{ github.repository }}/actions/workflows/sync-common.yml) ([source](${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/sync-common.yml)).
This PR synchronizes common files from the [infra repository](${{ github.server_url }}/${{ github.repository }}/tree/main/common).
Synchronized from ${{ github.repository }}@${{ github.sha }}.
committer: "bootc-dev Bot <bot@bootc.dev>"
author: "bootc-dev Bot <bot@bootc.dev>"
signoff: true