Skip to content

Commit

Permalink
Move prow job to Github Step (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cortey authored Dec 7, 2023
1 parent c990174 commit 57eb252
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o pipefail # prevents errors in a pipeline from being masked

# Expected variables:
# PULL_BASE_REF - name of the tag
# BOT_GITHUB_TOKEN - github token used to upload the template yaml
# GITHUB_TOKEN - github token used to upload the template yaml

uploadFile() {
filePath=${1}
Expand All @@ -17,7 +17,7 @@ uploadFile() {
echo "Uploading ${filePath} as ${ghAsset}"
response=$(curl -s -o output.txt -w "%{http_code}" \
--request POST --data-binary @"$filePath" \
-H "Authorization: token $BOT_GITHUB_TOKEN" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: text/yaml" \
$ghAsset)
if [[ "$response" != "201" ]]; then
Expand All @@ -39,7 +39,7 @@ cat serverless-operator.yaml
echo "Fetching releases"
CURL_RESPONSE=$(curl -w "%{http_code}" -sL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $BOT_GITHUB_TOKEN"\
-H "Authorization: Bearer $GITHUB_TOKEN"\
https://api.github.com/repos/kyma-project/serverless-manager/releases)
JSON_RESPONSE=$(sed '$ d' <<< "${CURL_RESPONSE}")
HTTP_CODE=$(tail -n1 <<< "${CURL_RESPONSE}")
Expand Down
25 changes: 25 additions & 0 deletions .github/scripts/verify-serverless-jobs-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

sleep 10

echo "Checking status of POST Jobs for Serverless"

REF_NAME="${1:-"main"}"
STATUS_URL="https://api.github.com/repos/kyma-project/serverless-manager/commits/${REF_NAME}/status"

function verify_github_jobs_status () {
local number=1
while [[ $number -le 100 ]] ; do
echo ">--> checking serverless job status #$number"
local STATUS=`curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL} | jq -r .state `
echo "jobs status: ${STATUS:='UNKNOWN'}"
[[ "$STATUS" == "success" ]] && return 0
[[ "$STATUS" == "failure" ]] && return 1
sleep 5
((number = number + 1))
done

exit 1
}

verify_github_jobs_status
19 changes: 0 additions & 19 deletions .github/scripts/verify-serverless-status.sh

This file was deleted.

12 changes: 11 additions & 1 deletion .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0

- name: Verify serverless manifest images
run: ./.github/scripts/verify-serverless-manifest-images.sh
run: ./.github/scripts/verify-serverless-jobs-manifest-images.sh

verify-head-status:
name: Verify HEAD
Expand Down Expand Up @@ -74,6 +74,16 @@ jobs:
git tag ${{ github.event.inputs.name }}
git push origin ${{ github.event.inputs.name }}
- name: Create release assets
id: create-assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_BASE_REF: ${{ github.event.inputs.name }}
run: ./.github/scripts/release.sh

- name: Verify Assets
run: ./.github/scripts/verify-serverless-jobs-status.sh ${{ github.ref_name }}

outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}

Expand Down

0 comments on commit 57eb252

Please sign in to comment.