Skip to content

Commit

Permalink
Use reusable workflows (#154)
Browse files Browse the repository at this point in the history
Update the github workflows to use the callable workflows in the `slapshot-reusable-workflows` repo.

J=SLAP-2005
TEST=auto

- See that the `coverage`, `update_docs`, and `run_tests` workflows run on this PR as expected.
- Test on another branch (`dev/test-reusable-workflows`) and see that docs are updated when needed.
- Fork the repo and commit to master. See that the `sync_develop_and_main` workflow creates a PR as expected.
  • Loading branch information
nmanu1 authored Apr 22, 2022
1 parent 1ede837 commit 3c8b63a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 78 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,7 @@ on:
pull_request:

jobs:
Coveralls:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npx jest --coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
call_code_coverage:
uses: yext/slapshot-reusable-workflows/.github/workflows/coverage.yml@v1
secrets:
caller_github_token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 4 additions & 16 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@ name: Run Tests
on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 15.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build-ci
- run: npm test
call_run_tests:
uses: yext/slapshot-reusable-workflows/.github/workflows/run_tests.yml@v1
with:
build_script: npm run build-ci
26 changes: 5 additions & 21 deletions .github/workflows/sync_develop_and_main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
name: create PR from main to develop
name: Create PR from main to develop

on:
push:
branches: [main, master]

permissions:
contents: read
pull-requests: write

jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: extract package version
id: vars
run: |
PACKAGE_VERSION="v$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')"
echo ::set-output name=tag::${PACKAGE_VERSION}
- uses: repo-sync/pull-request@v2
with:
source_branch: "${{ github.event.repository.default_branch }}"
destination_branch: "develop"
pr_title: "Merge ${{ github.event.repository.default_branch }} (${{ steps.vars.outputs.tag }}) into develop"
pr_body: "Merge ${{ github.event.repository.default_branch }} (${{ steps.vars.outputs.tag }}) into develop"
github_token: ${{ secrets.GITHUB_TOKEN }}
call_sync_develop_and_main:
uses: yext/slapshot-reusable-workflows/.github/workflows/sync_develop_and_main.yml@v1
secrets:
caller_github_token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 4 additions & 22 deletions .github/workflows/update_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,7 @@ name: Check and Update Repo's documenation
on: pull_request

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [17.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build-ci
- name: Update Documentation
uses: EndBug/add-and-commit@v7
with:
message: "Automated update to repo's documentation from github action"
add: '*.md'
push: true
default_author: github_actions
call_update_docs:
uses: yext/slapshot-reusable-workflows/.github/workflows/update_docs.yml@v1
with:
build_script: npm run build-ci

0 comments on commit 3c8b63a

Please sign in to comment.