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' ] python-version: [ '3.7', '3.8', '3.9', '3.10' ]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v3 - uses: ./.github/actions/setup
id: setup-python
with: with:
python-version: ${{ matrix.python-version }} 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: | - run: |
npm install -g gulp-cli npm install -g gulp-cli
npm install npm install
@ -74,6 +60,9 @@ jobs:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup
- name: Install Railway CLI
run: npm i -g @railway/cli
- name: Deploy demo - name: Deploy demo
run: npx railway up run: npx railway up
env: env:

View File

@ -20,23 +20,10 @@ jobs:
language: [ 'javascript', 'python' ] language: [ 'javascript', 'python' ]
steps: steps:
- uses: actions/checkout@v3 - 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 - uses: github/codeql-action/init@v2
with: with:
config-file: ./.github/codeql/codeql-config.yml config-file: ./.github/codeql/codeql-config.yml
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
setup-python-dependencies: false setup-python-dependencies: false
- name: Install dependencies - uses: ./.github/actions/setup
run: |
python -m pip install --upgrade pipenv wheel
pipenv install
- uses: github/codeql-action/analyze@v2 - uses: github/codeql-action/analyze@v2

View File

@ -12,23 +12,7 @@ jobs:
url: https://demo.baby-buddy.net url: https://demo.baby-buddy.net
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v3 - uses: ./.github/actions/setup
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'
- name: Install Railway CLI - name: Install Railway CLI
run: npm i -g @railway/cli run: npm i -g @railway/cli
- name: Reset demo database - name: Reset demo database