Skip to content

Commit

Permalink
deregister-runner no longer needs a job
Browse files Browse the repository at this point in the history
fix for ssh issue

moved step

created ssh dir and touched new file

a

b

changed perms to 400

changed user to ubuntu

added additional package to install for gh runner

install libicu

changed url

check for what the url is

another one

echo repo

changed repo name to static

a

changed auth type

B

added permissions for github token

e

ee

e

changed from github token to secret
  • Loading branch information
ehearneRedHat committed Jun 24, 2024
1 parent 703c4dd commit 0cee245
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
31 changes: 13 additions & 18 deletions .github/workflows/verify-dashboards-alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
# - examples/alerts/prometheusrules_policies_missing.yaml
# - examples/alerts/slo-availability.yaml
# - examples/alerts/slo-latency.yaml

jobs:
deploy-register-self-runner:
runs-on: ubuntu-latest
Expand All @@ -26,43 +25,40 @@ jobs:
- name: Create PEM file
run: |
echo "${{ secrets.AWS_PEM_KEY }}" > ${{ secrets.AWS_KEY_NAME }}.pem
chmod 600 ${{ secrets.AWS_KEY_NAME }}.pem
chmod 400 ${{ secrets.AWS_KEY_NAME }}.pem
- name: Apply Terraform Configuration + Extract Public IP
run: |
terraform apply -auto-approve -var=aws_access_key=${{ secrets.AWS_ACCESS_KEY_ID }} -var=aws_secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} -var=aws_key_name=${{ secrets.AWS_KEY_NAME }}
# Get the public IP address of the instance
echo "EC2_PUBLIC_IP=$(terraform output instance_public_ip)" >> $GITHUB_ENV
- name: Create PEM file
run: |
echo "${{ secrets.AWS_PEM_KEY }}" > ${{ secrets.AWS_KEY_NAME }}.pem
chmod 600 ${{ secrets.AWS_KEY_NAME }}.pem
- name: Generate Registration Token
id: reg_token
run: |
REPO_OWNER=${{ github.repository_owner }}
REPO_NAME=${{ github.event.repository.name }}
RESPONSE=$(curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
RESPONSE=$(curl -L \
-X POST \
-H "Authorization: Bearer ${{ secrets.REGISTRATION_PAT }}" \
https://github.com/gitapi/repos/$REPO_OWNER/$REPO_NAME/actions/runners/registration-token)
echo $RESPONSE
echo "REGISTRATION_TOKEN=$(echo $RESPONSE | jq -r .token)" >> $GITHUB_ENV
- name: SSH into EC2 Instance and Register Runner
env:
REGISTRATION_TOKEN: ${{ env.REGISTRATION_TOKEN }}
run: |
ssh -o StrictHostKeyChecking=no -i ${{ secrets.AWS_KEY_NAME }}.pem ec2-user@${{ env.EC2_PUBLIC_IP }} << EOF
sudo apt-get update -y
sudo apt-get install -y libicu-dev
ssh -o StrictHostKeyChecking=no -i ${{ secrets.AWS_KEY_NAME }}.pem ubuntu@${{ env.EC2_PUBLIC_IP }} << EOF
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.281.1.tar.gz -L https://github.com/actions/runner/releases/download/v2.281.1/actions-runner-linux-x64-2.281.1.tar.gz
tar xzf ./actions-runner-linux-x64-2.281.1.tar.gz
./config.sh --url https://github.com/${{ github.repository }} --token $REGISTRATION_TOKEN --unattended --labels self-hosted,linux,aws
./svc.sh install
./svc.sh start
curl -o actions-runner-linux-x64-2.317.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.317.0/actions-runner-linux-x64-2.317.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.317.0.tar.gz
./config.sh --url https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }} --token $REGISTRATION_TOKEN --unattended --labels self-hosted,linux,aws
./run.sh
EOF
verify-dashboards-alerts:
Expand Down Expand Up @@ -189,7 +185,6 @@ jobs:
deregister-runner:
runs-on: ubuntu-latest
needs: verify-dashboards-alerts

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion self-hosted-runner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ resource "aws_instance" "example" {
#!/bin/bash
echo "Starting user_data script..."
sudo apt-get update -y
sudo apt-get install -y podman golang
sudo apt-get install -y podman golang libicu-dev
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.30.0/2024-05-12/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p /home/ubuntu/bin && cp ./kubectl /home/ubuntu/bin/kubectl
Expand Down

0 comments on commit 0cee245

Please sign in to comment.