Use a composite action for job setup

This commit is contained in:
Christopher C. Wells 2022-06-02 21:34:04 -07:00
parent 99dd61bd17
commit 3c05768f0e
4 changed files with 34 additions and 46 deletions

28
.github/actions/setup/action.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Setup
description: Set up Baby Buddy environment and dependencies.
inputs:
python-version:
description: 'What Python version to use.'
required: false
default: '3.x'
runs:
using: 'composite'
steps:
- uses: actions/setup-python@v3
id: setup-python
with:
python-version: ${{ inputs.python-version }}
- uses: actions/cache@v3
with:
path: |
~/.local/share/virtualenvs
Pipfile.lock
key: ${{ runner.os }}-python-${{ inputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }}
- name: Install Python dependencies
shell: bash
run: |
python -m pip install --upgrade pipenv wheel
pipenv install --dev
- uses: actions/setup-node@v3
with:
node-version: 16

View File

@ -14,23 +14,9 @@ jobs:
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
id: setup-python
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
with:
path: |
~/.local/share/virtualenvs
Pipfile.lock
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pipenv wheel
pipenv install --dev
- uses: actions/setup-node@v3
with:
node-version: 16
- run: |
npm install -g gulp-cli
npm install
@ -74,6 +60,9 @@ jobs:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- name: Install Railway CLI
run: npm i -g @railway/cli
- name: Deploy demo
run: npx railway up
env:

View File

@ -20,23 +20,10 @@ jobs:
language: [ 'javascript', 'python' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
id: setup-python
with:
python-version: '3.x'
- uses: actions/cache@v3
with:
path: |
~/.local/share/virtualenvs
Pipfile.lock
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }}
- uses: github/codeql-action/init@v2
with:
config-file: ./.github/codeql/codeql-config.yml
languages: ${{ matrix.language }}
setup-python-dependencies: false
- name: Install dependencies
run: |
python -m pip install --upgrade pipenv wheel
pipenv install
- uses: ./.github/actions/setup
- uses: github/codeql-action/analyze@v2

View File

@ -12,23 +12,7 @@ jobs:
url: https://demo.baby-buddy.net
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
id: setup-python
with:
python-version: '3.x'
- uses: actions/cache@v3
with:
path: |
~/.local/share/virtualenvs
Pipfile.lock
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }}
- name: Install pipenv
run: python -m pip install --upgrade pipenv wheel
- name: Install dependencies
run: pipenv install
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: ./.github/actions/setup
- name: Install Railway CLI
run: npm i -g @railway/cli
- name: Reset demo database