Skip to content

Commit 96e05f7

Browse files
Create template for executing all data processing notebooks (#55)
Create a basic template that provisions an EC2 instance in a given AWS account. This template will eventually be used to execute all notebooks, but currently, the job is effectively a "Hello World" job for now. ##
1 parent ec58ba3 commit 96e05f7

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Execute All Notebooks
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
# FUTURE USE:
7+
# Maintainers can provide a PR number or existing upstream branch name to run this
8+
# job against. If no PR number or branch name is provided, this job will run against
9+
# content in the "main" branch instead.
10+
pr_or_branch:
11+
description: "Pull request number or branch name"
12+
required: true
13+
default: "main"
14+
15+
env:
16+
INSTANCE_TYPE: "g6e.xlarge"
17+
18+
# We don't need anything other than Bash for our shell..
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
jobs:
24+
launch-ec2-runner:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
id-token: write # This is required for OIDC (AWS auth)
28+
contents: read
29+
outputs:
30+
label: ${{ steps.start-ec2-runner.outputs.label }}
31+
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
37+
- name: Configure AWS Credentials
38+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0
39+
with:
40+
role-to-assume: "arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ vars.DATA_PROCESSING_IAM_ROLE }}"
41+
aws-region: us-east-2
42+
role-session-name: odh-data-processing # For tracking in CloudTrail
43+
44+
- name: Start Data Processing EC2 runner
45+
id: start-ec2-runner
46+
uses: machulav/ec2-github-runner@fcfb31a5760dad1314a64a0e172b78ec6fc8a17e # v4.3.2
47+
with:
48+
mode: start
49+
github-token: "${{ secrets.DATA_PROCESSING_GH_PERSONAL_ACCESS_TOKEN }}"
50+
ec2-image-id: "${{ vars.US_EAST_2_AMI_ID }}"
51+
ec2-instance-type: "${{ env.INSTANCE_TYPE }}"
52+
subnet-id: "${{ vars.US_EAST_2A_SUBNET_ID }}"
53+
security-group-id: "${{ vars.US_EAST_2_SG_ID }}"
54+
iam-role-name: "${{ vars.DATA_PROCESSING_IAM_ROLE }}"
55+
aws-resource-tags: >
56+
[
57+
{"Key": "Name", "Value": "data-processing-gh-runner"},
58+
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"},
59+
{"Key": "GitHubRef", "Value": "${{ github.ref }}"},
60+
{"Key": "GitHubPR", "Value": "${{ github.event.number }}"}
61+
]
62+
63+
execute-all-notebooks:
64+
needs:
65+
- launch-ec2-runner
66+
runs-on: ${{ needs.launch-ec2-runner.outputs.label }}
67+
68+
steps:
69+
- name: Setup Environment
70+
run: |
71+
echo "hello. i'm running from inside of EC2 instance ${{ needs.launch-ec2-runner.outputs.ec2-instance-id }}"
72+
73+
stop-ec2-runner:
74+
permissions:
75+
id-token: write # This is required for OIDC (AWS auth)
76+
contents: read
77+
needs:
78+
- launch-ec2-runner
79+
- execute-all-notebooks
80+
runs-on: ubuntu-latest
81+
if: ${{ always() }}
82+
steps:
83+
- name: Configure AWS credentials
84+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0
85+
with:
86+
role-to-assume: "arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ vars.DATA_PROCESSING_IAM_ROLE }}"
87+
aws-region: us-east-2
88+
role-session-name: odh-data-processing # For tracking in CloudTrail
89+
90+
- name: Stop EC2 runner
91+
uses: machulav/ec2-github-runner@fcfb31a5760dad1314a64a0e172b78ec6fc8a17e # v4.3.2
92+
with:
93+
mode: stop
94+
github-token: "${{ secrets.DATA_PROCESSING_GH_PERSONAL_ACCESS_TOKEN }}"
95+
label: ${{ needs.launch-ec2-runner.outputs.label }}
96+
ec2-instance-id: ${{ needs.launch-ec2-runner.outputs.ec2-instance-id }}

0 commit comments

Comments
 (0)