Skip to content

Commit 12f7ff9

Browse files
committed
initial commit
0 parents  commit 12f7ff9

3 files changed

Lines changed: 129 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build Package Tags
10+
runs-on: ubuntu-latest
11+
env:
12+
WP_DEVELOP_REPO: 'https://github.com/WordPress/wordpress-develop.git'
13+
WP_PHPUNIT_REPO: ${{ secrets.WP_PHPUNIT_REPO }}
14+
steps:
15+
- name: Generate token
16+
uses: tibdex/github-app-token@v1
17+
id: generate-token
18+
with:
19+
app_id: ${{ secrets.BOT_APP_ID }}
20+
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
21+
22+
- uses: actions/checkout@v3
23+
with:
24+
repository: wp-phpunit/build
25+
26+
- uses: actions/checkout@v3
27+
with:
28+
repository: wordpress/wordpress-develop
29+
path: repos/wordpress
30+
31+
- uses: actions/checkout@v3
32+
with:
33+
repository: ${{ format('wp-phpunit/{0}', secrets.TARGET_REPO_NAME) }}
34+
path: repos/package
35+
token: ${{ steps.generate-token.outputs.token }}
36+
37+
- name: Configure Git
38+
working-directory: repos/package
39+
run: |
40+
git config user.name "GitHub Actions"
41+
git config user.email "actions@github.com"
42+
43+
- name: Get Composer Cache Directory
44+
id: composer-cache
45+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
46+
- name: Cache PHP dependencies
47+
uses: actions/cache@v3
48+
id: actions-cache
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
52+
restore-keys: ${{ runner.os }}-composer-
53+
54+
- uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: '7.2'
57+
tools: composer:2.2
58+
59+
- run: composer install --prefer-dist --no-dev
60+
61+
- name: Run
62+
run: bin/build
63+
64+
- name: Push to repo
65+
run: bin/deploy

.github/workflows/check-tags.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Check Tags
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
check-tags:
8+
name: Check Tags
9+
runs-on: ubuntu-latest
10+
env:
11+
WP_DEVELOP_REPO: 'https://github.com/WordPress/wordpress-develop.git'
12+
WP_PHPUNIT_REPO: ${{ secrets.WP_PHPUNIT_REPO }}
13+
outputs:
14+
tags-to-build: ${{ steps.tags-to-build.outputs.result }}
15+
16+
steps:
17+
- name: Generate token
18+
uses: tibdex/github-app-token@v1
19+
id: generate-token
20+
with:
21+
app_id: ${{ secrets.BOT_APP_ID }}
22+
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
23+
24+
- name: Determine tags to build
25+
id: tags-to-build
26+
uses: actions/github-script@v6
27+
with:
28+
github-token: ${{ steps.generate-token.outputs.token }}
29+
debug: 'true'
30+
script: |
31+
const [wpTags, pkgTags] = await Promise.all([
32+
github.paginate(github.rest.repos.listTags, {
33+
owner: 'wordpress',
34+
repo: 'wordpress-develop',
35+
per_page: 100,
36+
}),
37+
github.paginate(github.rest.repos.listTags, {
38+
owner: context.repo.owner,
39+
repo: '${{ secrets.TARGET_REPO_NAME }}',
40+
per_page: 100,
41+
}),
42+
])
43+
function tagEligible(tag) {
44+
const [major, minor] = tag.split(/\./).map(Number);
45+
return major > 3 || (major === 3 && minor > 6)
46+
}
47+
const pkgTagNames = pkgTags.map(tag => tag.name);
48+
const tagsToBuild = wpTags.filter(
49+
tag => tagEligible(tag.name) && ! pkgTagNames.includes(tag.name)
50+
)
51+
return tagsToBuild.map(tag => tag.name);
52+
53+
- name: Inspect
54+
run: echo '${{ steps.tags-to-build.outputs.result }}' | jq
55+
56+
build-tags:
57+
name: Build Tags
58+
needs: check-tags
59+
if: needs.check-tags.tags-to-build != '[]'
60+
uses: ./.github/workflows/build.yml
61+
secrets: inherit

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Package Bot
2+
3+
This repo defines GitHub actions for publishing automated updates to [wp-phpunit](https://github.com/wp-phpunit/wp-phpunit).

0 commit comments

Comments
 (0)