From aeb425d73433670dcd67d439dea380c48121e22d Mon Sep 17 00:00:00 2001 From: Harsha Gazula Date: Mon, 2 Oct 2023 20:15:09 -0400 Subject: [PATCH] initial workflow commit --- .github/workflows/aws_test.yml | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/aws_test.yml diff --git a/.github/workflows/aws_test.yml b/.github/workflows/aws_test.yml new file mode 100644 index 0000000..78edb65 --- /dev/null +++ b/.github/workflows/aws_test.yml @@ -0,0 +1,57 @@ +name: Guide Notebooks Regression - EC2 +run-name: ${{ github.ref_name }} - Guide Notebooks Regression - EC2 +on: [push] +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@v1 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_KEY_SECRET }} + aws-region: ${{ vars.AWS_REGION }} + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + github-token: ${{ secrets.GH_TOKEN }} + ec2-image-id: ${{ vars.AWS_IMAGE_ID }} + ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} + subnet-id: ${{ vars.AWS_SUBNET }} + security-group-id: ${{ vars.AWS_SECURITY_GROUP }} + + do-the-job: + name: Do the job on the runner + needs: start-runner # required to start the main job when the runner is ready + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner + steps: + - name: Hello World + run: echo 'Hello World!' + + stop-runner: + name: Stop self-hosted EC2 runner + needs: + - start-runner # required to get output from the start-runner job + - guide_notebooks_regression_ec2 # 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@v1 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_KEY_SECRET }} + aws-region: ${{ vars.AWS_REGION }} + - name: Stop EC2 runner + uses: machulav/ec2-github-runner@v2 + with: + mode: stop + github-token: ${{ secrets.GH_TOKEN }} + label: ${{ needs.start-runner.outputs.label }} + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} \ No newline at end of file