From 4cb647a7f627de1b562787e6499f0df3823ce512 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Thu, 3 Nov 2022 14:32:44 -0500 Subject: [PATCH 1/4] ci: add workflow for updating package API snapshots --- .github/workflows/package_api.yml | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/package_api.yml diff --git a/.github/workflows/package_api.yml b/.github/workflows/package_api.yml new file mode 100644 index 000000000..11544baec --- /dev/null +++ b/.github/workflows/package_api.yml @@ -0,0 +1,48 @@ +name: Package API +on: + pull_request_target: + types: [labeled, opened, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + update: + runs-on: ubuntu-latest + if: ${{ github.event.pull_request.head.repo.full_name == 'primer/octicons' && contains(github.event.pull_request.labels.*.name, 'Update Public API') }} + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: yarn + - name: Install workspace dependencies + run: yarn + working-directory: lib/octicons_react + - name: Build project + run: yarn build + - name: Build package + run: yarn build + working-directory: lib/octicons_react + - name: Update snapshots + run: yarn test -u + - name: Sync to Pull Request + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Our git status is not clean. Checking in the following files:"; + echo "$(git status --porcelain)"; + git config --global credential.helper 'cache --timeout=120' + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git remote set-url origin "https://github.com/primer/octicons.git" + git add -A + git commit -m "chore(project): update @primer/octicons-react Public API" + git push + fi From 6d1583be67c54614e38748a7e3df657a6ebc93a7 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Mon, 7 Nov 2022 08:56:29 -0600 Subject: [PATCH 2/4] Update .github/workflows/package_api.yml --- .github/workflows/package_api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package_api.yml b/.github/workflows/package_api.yml index 11544baec..575cc8400 100644 --- a/.github/workflows/package_api.yml +++ b/.github/workflows/package_api.yml @@ -13,7 +13,7 @@ permissions: jobs: update: runs-on: ubuntu-latest - if: ${{ github.event.pull_request.head.repo.full_name == 'primer/octicons' && contains(github.event.pull_request.labels.*.name, 'Update Public API') }} + if: ${{ github.event.pull_request.head.repo.full_name == 'primer/octicons' && contains(github.event.pull_request.labels.*.name, 'api changes approved') }} steps: - name: Checkout default branch uses: actions/checkout@v3 From 07cbecf2e60f6d1b497db10c6233837a1ff7d647 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Mon, 7 Nov 2022 09:02:48 -0600 Subject: [PATCH 3/4] chore: add working-directory option --- .github/workflows/package_api.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package_api.yml b/.github/workflows/package_api.yml index 11544baec..ff2f1f1db 100644 --- a/.github/workflows/package_api.yml +++ b/.github/workflows/package_api.yml @@ -24,14 +24,15 @@ jobs: - name: Install dependencies run: yarn - name: Install workspace dependencies - run: yarn working-directory: lib/octicons_react + run: yarn - name: Build project run: yarn build - name: Build package - run: yarn build working-directory: lib/octicons_react + run: yarn build - name: Update snapshots + working-directory: lib/octicons_react run: yarn test -u - name: Sync to Pull Request run: | From 1bd9ede700a1c761969062d730132319a9aadde8 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Tue, 13 Dec 2022 12:47:12 -0600 Subject: [PATCH 4/4] Update package_api.yml --- .github/workflows/package_api.yml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/package_api.yml b/.github/workflows/package_api.yml index c55503e59..8dc480f97 100644 --- a/.github/workflows/package_api.yml +++ b/.github/workflows/package_api.yml @@ -1,10 +1,11 @@ name: Package API on: pull_request_target: - types: [labeled, opened, synchronize] + types: + - labeled concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.head_ref }} cancel-in-progress: true permissions: @@ -12,11 +13,16 @@ permissions: jobs: update: + if: > + github.event.pull_request.head.repo.full_name == 'primer/octicons' && + contains(github.event.pull_request.labels.*.name, 'api changes approved') }} runs-on: ubuntu-latest - if: ${{ github.event.pull_request.head.repo.full_name == 'primer/octicons' && contains(github.event.pull_request.labels.*.name, 'api changes approved') }} steps: - name: Checkout default branch uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.head_ref }} - uses: actions/setup-node@v3 with: node-version: '16.x' @@ -34,16 +40,9 @@ jobs: - name: Update snapshots working-directory: lib/octicons_react run: yarn test -u - - name: Sync to Pull Request - run: | - if [ -n "$(git status --porcelain)" ]; then - echo "Our git status is not clean. Checking in the following files:"; - echo "$(git status --porcelain)"; - git config --global credential.helper 'cache --timeout=120' - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - git remote set-url origin "https://github.com/primer/octicons.git" - git add -A - git commit -m "chore(project): update @primer/octicons-react Public API" - git push - fi + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'chore(project): update @primer/octicons-react Public API' + - uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: 'api changes approved'