Skip to content

Commit

Permalink
Merge pull request #211 from snow-actions/ci
Browse files Browse the repository at this point in the history
Move package to test.yml
  • Loading branch information
SnowCait committed Aug 11, 2022
2 parents 17126ad + 4788fe9 commit c5ba287
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 85 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,107 @@
name: CI
on:
pull_request:
push:
branches:
- main

jobs:
paths:
runs-on: ubuntu-22.04
timeout-minutes: 5
outputs:
package: ${{ steps.changes.outputs.package }}
test: ${{ steps.changes.outputs.test }}

steps:
- run: cat $GITHUB_EVENT_PATH
- uses: dorny/paths-filter@v2.10.2
id: changes
with:
filters: |
package:
- .github/workflows/package.yml
- dist/**
- src/**
- package-lock.json
- package.json
test:
- .github/workflows/test.yml
package:
needs: [ paths ]
if: needs.paths.outputs.package == 'true' && github.event_name == 'pull_request'
runs-on: ubuntu-20.04
timeout-minutes: 5

steps:
- id: generate_token
uses: tibdex/github-app-token@v1.6.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}
ref: ${{ github.head_ref }}
- run: npm install
- run: npm run format
- run: npm run build
- run: npm run lint
- run: npm run package
- name: Diff
id: diff
run: |
git status
git add -N .
git diff --name-only --exit-code
continue-on-error: true
- uses: snow-actions/git-config-user@v1.0.0
if: steps.diff.outcome == 'failure'
- name: Commit & Push
run: |
git add .
git commit -m 'npm run package'
git push
exit 1
if: steps.diff.outcome == 'failure'

test:
needs: [ paths, package ]
if: >-
failure() == false &&
cancelled() == false &&
(needs.paths.outputs.package == 'true' || needs.paths.outputs.test == 'true')
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Only latest because of API rate limit
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- uses: actions/checkout@v3
- id: tweet
uses: ./
env:
CONSUMER_API_KEY: ${{ secrets.CONSUMER_API_KEY }}
CONSUMER_API_SECRET_KEY: ${{ secrets.CONSUMER_API_SECRET_KEY }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
with:
status: ${{ matrix.os }} ${{ github.job }} ${{ github.run_id }} ${{ github.run_number }} ${{ github.ref }} ${{ github.sha }}
- run: test -n "${ID}"
env:
ID: ${{ fromJSON(steps.tweet.outputs.response).id_str }}

# Required status checks
passing:
needs: [ test ]
if: always()
runs-on: ubuntu-22.04
timeout-minutes: 5

steps:
- run: echo "$needs"
env:
needs: ${{ toJSON(needs) }}
- run: exit 1
if: (failure() == false && cancelled() == false) == false # success() || skipped()
46 changes: 0 additions & 46 deletions .github/workflows/package.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/test.yml

This file was deleted.

0 comments on commit c5ba287

Please sign in to comment.