Skip to content

Commit

Permalink
Add shared workflow setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
neild3r committed Sep 15, 2021
1 parent ba014fa commit 3e26ef7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 49 deletions.
23 changes: 23 additions & 0 deletions .github/actions/setup/action.yml
@@ -0,0 +1,23 @@
name: 'Setup'
description: 'Setup environment'
runs:
using: "composite"
steps:
- run: |
git config user.name "php-docblocker"
git config user.email php-docblocker@brayfield.co.uk
shell: bash
- uses: actions/setup-node@v1
with:
node-version: 14.x

- uses: actions/cache@v2
env:
cache-name: vscode
with:
path: ~/.vscode-test/
key: ${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}

- run: npm install
shell: bash
24 changes: 6 additions & 18 deletions .github/workflows/prepare-release.yml
Expand Up @@ -15,25 +15,12 @@ jobs:

- name: Checkout
uses: actions/checkout@v2
- run: |
git config user.name "php-docblocker"
git config user.email php-docblocker@brayfield.co.uk

- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Cache vscode binary
uses: actions/cache@v2
env:
cache-name: vscode
with:
path: ~/.vscode-test/
key: ${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
- name: Setup
uses: ./.github/actions/setup

- name: Install dependencies
run: npm install
- name: Verify PAT
run: npm run verify-pat -- --pat ${{ secrets.VSCE_PAT }}

- name: Update version number
run: |
Expand All @@ -49,6 +36,7 @@ jobs:
git commit -m "Release ${{ env.npm_package_version }}"
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v3
with:
author: php-docblocker <php-docblocker@brayfield.co.uk>
Expand All @@ -64,4 +52,4 @@ jobs:
uses: peter-evans/enable-pull-request-automerge@v1
with:
token: ${{ secrets.BOT_GITHUB_PAT }}
pull-request-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
pull-request-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
18 changes: 2 additions & 16 deletions .github/workflows/release.yml
Expand Up @@ -10,28 +10,14 @@ jobs:
github.event.pull_request.merged == true
&& github.event.pull_request.user.login == 'php-docblocker'
&& contains(github.event.pull_request.labels.*.name, 'release candidate')
name: Release PR Merged
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Cache vscode binary
uses: actions/cache@v2
env:
cache-name: vscode
with:
path: ~/.vscode-test/
key: ${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm install
- name: Setup
uses: ./.github/actions/setup

- name: Verify PAT
run: npm run verify-pat -- --pat ${{ secrets.VSCE_PAT }}
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/test.yml
Expand Up @@ -13,21 +13,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Cache vscode binary
uses: actions/cache@v2
env:
cache-name: vscode
with:
path: ~/.vscode-test/
key: ${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm install
- name: Setup
uses: ./.github/actions/setup

- name: Run tests
run: xvfb-run -a npm test
Expand Down

0 comments on commit 3e26ef7

Please sign in to comment.