Skip to content

Commit c281e89

Browse files
committed
commit to infra repo using gh action
1 parent bd241d4 commit c281e89

File tree

2 files changed

+155
-8
lines changed

2 files changed

+155
-8
lines changed

.github/workflows/staging-deploy-action.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,25 @@ jobs:
188188
- name: Push
189189
run: docker push ${{ needs.update-version.outputs.okr-docker-image}}
190190

191-
- name: Install yq
192-
shell: bash
193-
env:
194-
VERSION: v4.25.2
195-
BINARY: yq_linux_amd64
191+
# - name: Install yq
192+
# shell: bash
193+
# env:
194+
# VERSION: v4.25.2
195+
# BINARY: yq_linux_amd64
196+
# run: |
197+
# wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
198+
# tar xz && mv ${BINARY} /usr/local/bin/yq
199+
200+
- name: 'Setup yq'
201+
uses: dcarbone/install-yq-action@v1
202+
with:
203+
# version: '${{ inputs.version }}'
204+
download-compressed: 'true'
205+
206+
- name: 'Check yq'
196207
run: |
197-
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
198-
tar xz && mv ${BINARY} /usr/local/bin/yq
208+
which yq
209+
yq --version
199210
200211
- name: Update YAML file
201212
shell: bash

.github/workflows/test-action.yml

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ on:
77
type: choice
88
description: Select type of deployment
99
options:
10+
- Release from Commit
1011
- Major
1112
- Minor
1213
- Patch
13-
- Release from Commit
14+
default: 'Release from Commit'
1415
commit_hash:
1516
description: 'The hash of thee commit that should be deployed, defaults to the latest commit on main'
1617
required: false
@@ -39,8 +40,17 @@ jobs:
3940
echo "deployment_type is ${{ github.event.inputs.deployment_type }}" / ${{ inputs.deployment_type }}
4041
echo "commit_hash is ${{ github.event.inputs.commit_hash }}" / ${{ inputs.commit_hash }}
4142
43+
verify-input:
44+
runs-on: ubuntu-24.04
45+
steps:
46+
- name: Verify input
47+
run: |
48+
echo "deployment_type is ${{ github.event.inputs.deployment_type }}" / ${{ inputs.deployment_type }}
49+
echo "commit_hash is ${{ github.event.inputs.commit_hash }}" / ${{ inputs.commit_hash }}
50+
echo "deployment is ${{ github.event.inputs.deployment }}" / ${{ inputs.deployment }}
4251
find-commit:
4352
runs-on: ubuntu-24.04
53+
needs: verify-input
4454
outputs:
4555
COMMIT_HASH: "${{ env.COMMIT_HASH }}"
4656
SHORT_COMMIT_HASH: "${{ env.SHORT_COMMIT_HASH }}"
@@ -175,6 +185,132 @@ jobs:
175185
name: okr-image
176186
path: /tmp/okr-docker-image.tar
177187

188+
e2e-docker:
189+
runs-on: ubuntu-24.04
190+
needs: [ build-docker-image,update-version]
191+
strategy:
192+
fail-fast: false
193+
matrix:
194+
file: ${{ fromJSON('[login.cy.ts]') }}
195+
196+
steps:
197+
- uses: actions/checkout@v4
198+
199+
- name: Download artifact
200+
uses: actions/download-artifact@v4
201+
with:
202+
name: okr-image
203+
path: /tmp
204+
205+
- name: Load image
206+
run: docker load --input /tmp/okr-docker-image.tar
207+
208+
- name: Run keyloak server
209+
run: cd docker && docker compose up -d keycloak-pitc
210+
211+
- name: run Springboot okr application
212+
run: |
213+
docker run --network=host \
214+
-e SPRING_PROFILES_ACTIVE=integration-test \
215+
${{ needs.update-version.outputs.okr-docker-image}} &
216+
217+
- name: set node version
218+
uses: actions/setup-node@v4
219+
with:
220+
node-version: ${{vars.NODE_VERSION}}
221+
222+
- name: Cypress run e2e tests
223+
uses: cypress-io/github-action@v6
224+
with:
225+
build: npm i -D cypress
226+
working-directory: frontend
227+
install: false
228+
wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544'
229+
wait-on-timeout: 120
230+
browser: chrome
231+
headed: false
232+
config: baseUrl=http://pitc.okr.localhost:8080
233+
spec: cypress/e2e/${{ matrix.file }}
234+
235+
- uses: actions/upload-artifact@v4
236+
if: always()
237+
with:
238+
name: cypress-screenshots for ${{ matrix.file }}
239+
path: frontend/cypress/screenshots
240+
241+
242+
upload-to-quay:
243+
runs-on: ubuntu-latest
244+
needs: [update-version, e2e-docker] #[e2e-docker, update-version]
245+
steps:
246+
- name: Checkout project
247+
uses: actions/checkout@v4
248+
249+
- name: Download artifact
250+
uses: actions/download-artifact@v4
251+
with:
252+
name: okr-image
253+
path: /tmp
254+
255+
- name: Load image
256+
run: docker load --input /tmp/okr-docker-image.tar
257+
258+
- name: show images
259+
run: docker image ls -a
260+
261+
- name: Log in to Quay registry
262+
uses: docker/login-action@v3
263+
with:
264+
registry: ${{ secrets.QUAY_REGISTRY }}
265+
username: ${{ secrets.QUAY_USERNAME }}
266+
password: ${{ secrets.QUAY_TOKEN }}
267+
268+
- name: Push
269+
run: docker push ${{ needs.update-version.outputs.okr-docker-image}}
270+
271+
# - name: Install yq
272+
# shell: bash
273+
# env:
274+
# VERSION: v4.25.2
275+
# BINARY: yq_linux_amd64
276+
# run: |
277+
# wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
278+
# tar xz && mv ${BINARY} /usr/local/bin/yq
279+
280+
deploy-release:
281+
runs-on: ubuntu-latest
282+
needs:
283+
- upload-to-quay
284+
steps:
285+
- uses: actions/checkout@v2
286+
with:
287+
repository: ${{env.GITOPS_REPO}}
288+
token: secrets.GITLAB_ACCESS_TOKEN
289+
290+
- uses: imranismail/setup-kustomize@v1
291+
with:
292+
kustomize-version: 4.0.0
293+
294+
- run: kustomize edit set image ${{env.APP_IMAGE}}:${GITHUB_REF#refs/*/}
295+
working-directory: apps/${{env.APP_NAME}}/overlays/test
296+
297+
- run: |
298+
git config user.email "[email protected]"
299+
git config user.name "gitops"
300+
git commit -am "Gitops update to $APP_NAME"
301+
git pull --rebase
302+
git push
303+
- name: Update YAML file
304+
shell: bash
305+
env:
306+
COMMITPREFIX: '[CTS]'
307+
run: |
308+
309+
curl -s --header "PRIVATE-TOKEN: ${{}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml
310+
yq -i "${{vars.YAML_PATH}} = \"${{needs.update-version.outputs.okr-docker-image}}\"" response.yaml
311+
UPDATED_CONTENT=$(cat response.yaml)
312+
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}"
313+
178314
# create-release:
179315
# runs-on: ubuntu-24.04
180316
# needs: update-version

0 commit comments

Comments
 (0)