Skip to content

Update main.yml

Update main.yml #57

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:
set-timestamp:
runs-on: ubuntu-latest
outputs:
timestamp: ${{ steps.get-timestamp.outputs.timestamp }}
steps:
- name: Get current timestamp
id: get-timestamp
run: echo "::set-output name=timestamp::$(date -u +'%Y%m%d-%H%M')"
build-and-upload-artifact:
runs-on: ubuntu-latest
needs: set-timestamp
env:
TIMESTAMP: ${{ needs.set-timestamp.outputs.timestamp }}
PYGEOAPI_CONFIG: "$(pwd)/pygeoapi-config.yml"
strategy:
matrix:
node-version: [20.x]
include:
- python-version: '3.10'
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: 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.TIMESTAMP }}
path: ${{ github.workspace }}/temp
copy-artifact-to-dev-branch:
runs-on: ubuntu-latest
needs: [set-timestamp, build-and-upload-artifact]
env:
TIMESTAMP: ${{ needs.set-timestamp.outputs.timestamp }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download zipped artifact
uses: actions/download-artifact@v4
with:
name: cgp_pygeoapi-${{ env.TIMESTAMP }}
path: ${{ github.workspace }}/temp
- name: Create new dev branch and overwrite artifact with force push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "bo-lu"
git config --global user.email "bo.lu@nrcan-rncan.gc.ca"
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