Skip to content

do-the-job

do-the-job #33

Workflow file for this run

name: do-the-job
on:
workflow_dispatch:
jobs:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.PAT }}
ec2-image-id: ami-007855ac798b5175e # ubuntu server
ec2-instance-type: t3.medium
subnet-id: subnet-0b200e65fcb7e2cb3
security-group-id: sg-003dfa64aa23c1374
#iam-role-name: github-actions # optional, requires additional permissions
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
do-the-job:
name: Do the job on the runner py${{ matrix.python-version }}
runs-on: ${{ needs.start-runner.outputs.label }}
defaults:
run:
shell: bash -l {0}
env:
HOME: /home/ubuntu
strategy:
fail-fast: false
matrix:
# Bookend python versions
python-version: ["3.9"]
needs: start-runner # required to start the main job when the runner is ready
steps:
- name: Check out
uses: actions/checkout@v4
- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ""
auto-activate-base: true
miniforge-variant: Mambaforge
- name: Install dependencies
run: |
mamba env create -n cordex-aws -f ci/environment.yaml
conda init bash
- name: List conda environment
run: |
conda env list
conda activate cordex-aws
conda list
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- do-the-job # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.PAT }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}