Skip to content

Commit 8051f5a

Browse files
author
Sunil Thaha
authored
Merge pull request #2288 from vprashar2929/ci-oracle-bm
ci: switch from Equinix to self hosted runners
2 parents 56f67b7 + 83cb6c2 commit 8051f5a

File tree

3 files changed

+20
-139
lines changed

3 files changed

+20
-139
lines changed

.github/clean-equinix-runner/action.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/create-equinix-runner/action.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/k8s-equinix.yaml renamed to .github/workflows/k8s-bm.yaml

Lines changed: 20 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
name: Build and Deploy K8s on Equinix
1+
name: Build and Deploy K8s on Self Hosted BM
22

33
on: #yamllint disable-line rule:truthy
4-
pull_request_target:
5-
# In order to trigger this workflow on comment, GH accepts the workflow to be available in the default branch only.
6-
# issue_comment:
7-
# types: [created]
4+
pull_request:
85

96
permissions:
107
pull-requests: write
@@ -25,83 +22,19 @@ jobs:
2522
with:
2623
filters: |
2724
changes:
28-
- '.github/workflows/k8s-equinix.yaml'
2925
- 'cmd/**/*.go'
3026
- 'internal/**/*.go'
3127
- 'config/**/*.go'
3228
- 'go.mod'
3329
- 'go.sum'
34-
create-runner:
35-
needs: check-changes
36-
if: needs.check-changes.outputs.changes == 'true'
37-
# TODO: Uncomment once we enable workflow on issue_comment
38-
# if: github.event.issue.pull_request && contains(github.event.comment.body, '/test-equinix')
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: Checkout source
42-
uses: actions/checkout@v5
43-
with:
44-
ref: ${{ github.event.pull_request.head.sha }}
45-
46-
- name: Create Equinix runner
47-
uses: ./.github/create-equinix-runner
48-
with:
49-
github_token: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
50-
metal_auth_token: ${{ secrets.EQUINIX_API_TOKEN }}
51-
metal_project_id: ${{ secrets.EQUINIX_PROJECT_ID }}
52-
os_name: ubuntu_22_04
5330
5431
build-and-deploy:
55-
needs: [check-changes, create-runner]
32+
# NOTE: In case of self-hosted runners, tools like docker, make, kubectl etc. are installed at the time of setting up the runner.
33+
# Hence, we don't need to install them as part of the job.
34+
needs: [check-changes]
5635
if: needs.check-changes.outputs.changes == 'true'
5736
runs-on: self-hosted
58-
env:
59-
GOCACHE: /home/ghrunner/.cache/go-build
60-
HOME: /home/ghrunner
61-
outputs:
62-
runner_name: ${{ runner.name }}
6337
steps:
64-
- name: Install Docker
65-
shell: bash
66-
run: |
67-
sudo apt-get update
68-
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
69-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
70-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
71-
sudo apt-get update
72-
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
73-
sudo usermod -aG docker root
74-
75-
- name: Verify Docker installation
76-
shell: bash
77-
run: |
78-
docker ps
79-
docker --version
80-
81-
- name: Install Kind
82-
shell: bash
83-
run: |
84-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64
85-
chmod +x ./kind
86-
sudo mv ./kind /usr/local/bin/kind
87-
88-
- name: Verify Kind installation
89-
shell: bash
90-
run: |
91-
kind version
92-
93-
- name: Install Kubectl
94-
shell: bash
95-
run: |
96-
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
97-
chmod +x ./kubectl
98-
sudo mv ./kubectl /usr/local/bin/kubectl
99-
100-
- name: Verify Kubectl installation
101-
shell: bash
102-
run: |
103-
kubectl version --client
104-
10538
- name: Checkout source
10639
uses: actions/checkout@v5
10740
with:
@@ -201,19 +134,25 @@ jobs:
201134
curl -s http://localhost:28282/metrics || true
202135
echo "::endgroup::"
203136
204-
cleanup-runner:
137+
cleanup:
205138
needs: [check-changes, build-and-deploy]
206-
runs-on: ubuntu-latest
207-
if: always() && needs.check-changes.outputs.changes == 'true' # Run even if the previous job fails
139+
runs-on: self-hosted
140+
# NOTE: Run even if the previous job fails
141+
if: always() && needs.check-changes.outputs.changes == 'true'
208142
steps:
209143
- name: Checkout source
210144
uses: actions/checkout@v5
211145
with:
212146
ref: ${{ github.event.pull_request.head.sha }}
213147

214-
- name: Clean Equinix runner
215-
uses: ./.github/clean-equinix-runner
216-
with:
217-
runner_name: ${{ needs.build-and-deploy.outputs.runner_name }}
218-
project_id: ${{ secrets.EQUINIX_PROJECT_ID }}
219-
api_token: ${{ secrets.EQUINIX_API_TOKEN }}
148+
# NOTE: Ensure that all deployments and built images are properly cleaned up
149+
# to prevent residual resources
150+
- name: Undeploy Kepler
151+
shell: bash
152+
run: |
153+
make undeploy
154+
155+
- name: Clean Docker images
156+
shell: bash
157+
run: |
158+
docker image prune -af

0 commit comments

Comments
 (0)