Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH action to generate report #199

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions .github/manifests/hello-world-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# manifests/hello-world-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: hello-world-pod
spec:
containers:
- name: hello
image: busybox
command: ['sh', '-c', 'echo Hello, World! && sleep 30']
nodeSelector:
NodeGroupType: default
NodePool: default
hub.jupyter.org/node-purpose: user
tolerations:
- key: "hub.jupyter.org/dedicated"
operator: "Equal"
value: "user"
effect: "NoSchedule"

64 changes: 64 additions & 0 deletions .github/workflows/report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Generate Data Usage Report

on:
pull_request:
branches:
- main
Comment on lines +4 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also run this on a weekly basis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's on PR push just so I can test easily, but yes, 1/week sounds good to me. @kabilar Do you have a preference for what day/time?

Copy link
Member

@kabilar kabilar Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you. How about Mondays at 6am EST? We can then review the report on Monday mornings.


jobs:
generate_data_usage_report:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# TODO param region
aws-region: us-east-2

- name: Assume JupyterhubProvisioningRole
# TODO param ProvisioningRoleARN and name ^
run: |
ROLE_ARN="arn:aws:iam::278212569472:role/JupyterhubProvisioningRole"
CREDS=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name "GitHubActionsSession")
export AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r '.Credentials.AccessKeyId')
export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r '.Credentials.SecretAccessKey')
export AWS_SESSION_TOKEN=$(echo $CREDS | jq -r '.Credentials.SessionToken')


- name: Configure kubectl with AWS EKS
# TODO param name, region role-arn
run: |
aws eks update-kubeconfig --name eks-dandihub --region us-east-2 --role-arn arn:aws:iam::278212569472:role/JupyterhubProvisioningRole

- name: Sanity check
run: |
kubectl get pods -n jupyterhub

# Step 4: Deploy Hello World Pod from manifest
- name: Deploy Hello World Pod
run: |
kubectl apply -f .github/manifests/hello-world-pod.yaml

# Step 5: Wait for Pod to Complete
- name: Wait for Hello World Pod to complete
run: |
kubectl wait --for=condition=Ready pod/hello-world-pod --timeout=300s # 5 minutes
continue-on-error: true # Allow the workflow to continue even if this step fails

# Step 6: Get Pod Logs to verify it ran successfully, only if Step 5 succeeds
- name: Get Hello World Pod logs
run: |
kubectl logs hello-world-pod
if: ${{ success() }} # Only run this step if the previous step was successful

# Step 7: Cleanup - Always run this step, even if previous steps fail
- name: Delete Hello World Pod
run: |
kubectl delete pod hello-world-pod
if: ${{ always() }} # Always run this step, even if other steps fail
Loading