-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,73 @@ | ||
# name: Generate Data Usage Report | ||
# | ||
# on: | ||
# pull_request: | ||
# branches: | ||
# - main | ||
# | ||
--- | ||
name: Generate Data Usage Report | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
generate-jobs-usage-report: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- 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 }} | ||
aws-region: us-east-2 | ||
|
||
- name: Launch EC2 Instance | ||
id: launch_ec2 | ||
run: | | ||
INSTANCE_ID=$(aws ec2 run-instances \ | ||
--image-id ami-0c02fb55956c7d316 \ | ||
--count 1 \ | ||
--instance-type t3.micro \ | ||
--key-name dandihub-gh-actions \ | ||
--security-group-ids sg-xxxxxxxx \ | ||
--subnet-id subnet-xxxxxxxx \ | ||
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=EC2dfTest}]" \ | ||
--query 'Instances[0].InstanceId' --output text) | ||
echo "INSTANCE_ID=${INSTANCE_ID}" >> $GITHUB_ENV | ||
- name: Wait for EC2 to Initialize | ||
run: | | ||
aws ec2 wait instance-status-ok --instance-ids ${{ env.INSTANCE_ID }} | ||
- name: Retrieve EC2 Public IP | ||
id: get_ip | ||
run: | | ||
PUBLIC_IP=$(aws ec2 describe-instances \ | ||
--instance-ids ${{ env.INSTANCE_ID }} \ | ||
--query 'Reservations[0].Instances[0].PublicIpAddress' --output text) | ||
echo "PUBLIC_IP=${PUBLIC_IP}" >> $GITHUB_ENV | ||
- name: Execute df Command on EC2 | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.PUBLIC_IP }} | ||
username: ec2-user | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
echo "Running df command on EC2 instance..." | ||
df -h | ||
echo "Command completed." | ||
- name: Terminate EC2 Instance | ||
run: | | ||
aws ec2 terminate-instances --instance-ids ${{ env.INSTANCE_ID }} | ||
aws ec2 wait instance-terminated --instance-ids ${{ env.INSTANCE_ID }} | ||
# jobs: | ||
# generate_data_usage_report: | ||
# runs-on: ubuntu-latest | ||
# | ||
# steps: | ||
# - name: Checkout code | ||
# uses: actions/checkout@v3 | ||
# | ||
# - name: Log in to DockerHub | ||
# uses: docker/login-action@v2 | ||
|