This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
160 lines (135 loc) · 4.68 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CI Workflow
on:
pull_request:
branches:
- main
jobs:
block-pr:
runs-on: ubuntu-latest
steps:
- name: Check if PR is from forked repo
id: check_forked
run: |
if [[ ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.event.pull_request.base.repo.full_name }} ]]; then
echo "This pull request was pushed from a forked repository, which is not allowed. Please push changes from a branch in the upstream repository"
exit 1
else
echo "This PR is from upstream repo."
fi
ci:
runs-on: ubuntu-latest
needs: block-pr
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- run: ansible-galaxy install -r ./provision/requirements.yml
- uses: pre-commit/[email protected]
- name: Setup
uses: hashicorp/[email protected]
with:
terraform_version: 1.3.7
- uses: eLco/[email protected]
with:
terragrunt_version: 0.43.0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
with:
role-to-assume: ${{ secrets.ROLE }}
aws-region: eu-west-2
- name: Plan
run: make ENV=ci plan-in-container
crc-cloud:
runs-on: ubuntu-latest
needs: block-pr
permissions:
id-token: write
contents: write
steps:
- name: Write pullsecret
env:
PULLSECRET_BASE64: ${{ secrets.PS_64 }}
run: |
echo $PULLSECRET_BASE64 | base64 --decode > pullsecret.txt
- name: Write boot key
run: |
echo "${{ secrets.ID_ECDSA }}" > key.txt
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
with:
role-to-assume: ${{ secrets.ROLE }}
aws-region: eu-west-2
- name: Create cluster
run: |
docker run -d --name crc-cloud-create --rm \
-v ${PWD}:/workspace:z \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
-e AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} \
-e AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
quay.io/crcont/crc-cloud:v0.0.2 \
create aws \
--project-name "crc-ocp412" \
--backed-url "file:///workspace" \
--output "/workspace" \
--aws-ami-id "ami-019669c0960dbcf14" \
--pullsecret-filepath /workspace/pullsecret.txt \
--key-filepath /workspace/key.txt
- name: View cluster creation logs
continue-on-error: true
run: |
docker logs -f crc-cloud-create
- name: Check cluster config
continue-on-error: true
run: |
ls -al /tmp
pwd
ls -al
ssh -i id_rsa core@$(cat host) "cat /opt/kubeconfig"
- name: Destroy cluster
run: |
docker run -d --name crccloud-destroy --rm \
-v ${PWD}:/workspace:z \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
-e AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} \
-e AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
quay.io/crcont/crc-cloud:v0.0.2 \
destroy \
--project-name "crc-ocp412" \
--backed-url "file:///workspace" \
--provider "aws"
- name: View cluster destroy logs
run: |
docker logs -f crccloud-destroy
build-and-push-image:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
runs-on: ubuntu-latest
needs: [ci, crc-cloud]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ./consumer
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}