Skip to content

Update main.yml

Update main.yml #53

Workflow file for this run

name: Build cgp-pygeoapi
on:
push:
branches:
- production
- bo_gh_actions_test
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-and-upload-artifact:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
include:
- python-version: '3.10'
env:
PYGEOAPI_CONFIG: "$(pwd)/pygeoapi-config.yml"
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Clear up GitHub runner diskspace
run: |
echo "Space before"
df -h /
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
echo "Space after"
df -h /
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Setup Python ${{ matrix.python-version }}
with:
python-version: ${{ matrix.python-version }}
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Install requirements
run: |
pip3 install -r requirements.txt
python3 setup.py install
- name: Build translations
run: |
pybabel extract -F babel-mapping.ini -o locale/messages.pot .
pybabel update -d locale -l en -i locale/messages.pot
pybabel update -d locale -l fr -i locale/messages.pot
pybabel compile -d locale -l en
pybabel compile -d locale -l fr
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Plugin and Deploy
uses: serverless/github-action@v3.2
with:
# The following only installs the extensions and creates a serverless package.
# To deploy, comment the line below and uncomment the second args line instead.
# Deployment requires AWS credentials
args: -c "serverless plugin install --name serverless-python-requirements && serverless plugin install --name serverless-wsgi && serverless package"
# args: -c "serverless plugin install --name serverless-python-requirements && serverless plugin install --name serverless-wsgi && serverless package && serverless deploy"
entrypoint: /bin/sh
- name: Set current date as env variable
run: echo "NOW=$(date +'%Y%m%d-%H%M')" >> $GITHUB_ENV
- name: Post packaging steps necessary to prevent a twice zipped deployment file
run: |
mkdir temp
unzip -o ${{ github.workspace }}/.serverless/pygeoapi.zip -d temp
- name: Upload zip file artifact
uses: actions/upload-artifact@v4
with:
name: cgp_pygeoapi-${{ env.NOW }}
path: ${{ github.workspace }}/temp
copy-artifact-to-dev-branch:
runs-on: ubuntu-latest
needs: build-and-upload-artifact
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download zipped artifact
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/temp
- name: Create new dev branch and overwrite artifact with force push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch_name="dev-release"
git checkout -b $branch_name
git add ${{ github.workspace }}/temp
git commit -m "Add artifact from workflow run ${{ github.run_id }}"
git push -u origin $branch_name