Skip to content

Commit

Permalink
Score Humanitec - New route support (#69)
Browse files Browse the repository at this point in the history
* Update humanitec.score.yaml - new route support

* Update score.yaml - New route support

* Update score.yaml

* Update score.yaml - workaround

* humctl 0.1.0

* Update score.yaml - raise errors for now

* Update open-pr.yml - catch failed status

* Update open-pr.yml - display errors

* Update open-pr.yml

* Update open-pr.yml

* Update open-pr.yml - elif

* Update open-pr.yml - errors formatting

* Update open-pr.yml

* Update open-pr.yml

* Update open-pr.yml

* Update open-pr.yml

* Update score.yaml

* Update open-pr.yml - ${{ github.env }}

* Update push-tag.yml - ${{ github.* }}
  • Loading branch information
mathieu-benoit authored Aug 23, 2023
1 parent bfa56a1 commit 4b823b6
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
Binary file modified .github/workflows/bin/humctl
Binary file not shown.
52 changes: 42 additions & 10 deletions .github/workflows/open-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
run: |
echo "IMAGE_DIGEST=$(oras manifest fetch ${{ env.IMAGE_NAME }}:${{ env.ENVIRONMENT_ID }} \
--descriptor \
| jq -r .digest)" >> $GITHUB_ENV
| jq -r .digest)" >> ${{ github.env }}
- name: install score-humanitec
uses: score-spec/setup-score@v2
with:
Expand All @@ -179,26 +179,30 @@ jobs:
- name: wait for deployment
run: |
sleep 1
IS_DONE=false
CURRENT_STATUS=""
while [ "$IS_DONE" = false ]; do
CURRENT_STATUS=$(.github/workflows/bin/humctl get environment ${{ env.ENVIRONMENT_ID }} -o json \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--context /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }} \
| jq -r .object.last_deploy.status)
INPROGRESS="in progress"
if [ "$CURRENT_STATUS" = "$INPROGRESS" ]; then
if [ "$CURRENT_STATUS" = "in progress" ]; then
echo "Deployment still in progress..."
sleep 1
elif [ "$CURRENT_STATUS" = "failed" ]; then
echo "Deployment failed!"
IS_DONE=true
else
echo "Deployment complete!"
echo "Deployment successfully completed!"
IS_DONE=true
fi
done
echo $CURRENT_STATUS
if [ "$CURRENT_STATUS" = "failed" ]; then
exit 1
fi
- name: build comment message
if: ${{ always() }}
run: |
ENV_URL=$(jq -r ".metadata.url" score_output.json)
DEPLOYMENT_ID=$(jq -r ".id" score_output.json)
Expand All @@ -207,8 +211,35 @@ jobs:
--context /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }} -o json \
| jq -r '. | map(. | select(.object.type == "dns")) | map((.object.res_id | split(".") | .[1]) + ": [" + .object.resource.host + "](https://" + .object.resource.host + ")") | join("\n")')
echo "## Deployment Complete for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt
echo "" >> pr_message.txt
DEPLOYMENT_ERRORS=$(.github/workflows/bin/humctl get deployment-error \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--context /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }} -o json)
if [ "$DEPLOYMENT_ERRORS" = "[]" ]; then
echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt
echo "" >> pr_message.txt
else
echo "## Deployment failed for ${{ env.ENVIRONMENT_NAME }}! :x:" >> pr_message.txt
echo "" >> pr_message.txt
echo "### Errors:" >> pr_message.txt
echo "" >> pr_message.txt
echo '```json' >> pr_message.txt
echo "" >> pr_message.txt
echo "$DEPLOYMENT_ERRORS" | jq .[0].object.message -r >> pr_message.txt
echo "" >> pr_message.txt
echo '```' >> pr_message.txt
echo "" >> pr_message.txt
echo "<details><summary>Errors details</summary>" >> pr_message.txt
echo "" >> pr_message.txt
echo "### Errors details:" >> pr_message.txt
echo '```json' >> pr_message.txt
echo "" >> pr_message.txt
echo "$DEPLOYMENT_ERRORS" >> pr_message.txt
echo "" >> pr_message.txt
echo '```' >> pr_message.txt
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt
echo "" >> pr_message.txt
fi
echo "### [View in Humanitec]($ENV_URL)" >> pr_message.txt
echo "Deployment ID: $DEPLOYMENT_ID" >> pr_message.txt
Expand Down Expand Up @@ -245,6 +276,7 @@ jobs:
cat pr_message.txt
- name: comment pr
if: ${{ always() }}
uses: thollander/actions-comment-pull-request@v2
with:
filePath: pr_message.txt
8 changes: 4 additions & 4 deletions .github/workflows/push-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
tags:
- 'v*'
env:
IMAGE_TAG: ${GITHUB_REF_NAME}
IMAGE_TAG: ${{ github.ref.name }}
IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/${{ vars.APP_NAME }}
ENVIRONMENT_ID: development
SCORE_HUMANITEC_VERSION: 'latest'
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
run: |
echo "IMAGE_DIGEST=$(oras manifest fetch ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
--descriptor \
| jq -r .digest)" >> $GITHUB_ENV
| jq -r .digest)" >> ${{ github.env }}
- name: notify humanitec
run: |-
.github/workflows/bin/humctl api POST /orgs/${{ secrets.HUMANITEC_ORG }}/artefact-versions \
Expand All @@ -104,8 +104,8 @@ jobs:
"version": "'${{ env.IMAGE_TAG }}'",
"digest": "'${IMAGE_DIGEST}'",
"type": "container",
"commit": "'$(echo ${GITHUB_SHA} | cut -c1-7)'",
"ref": "'${GITHUB_REF}'"
"commit": "'$(echo ${{ github.sha }} | cut -c1-7)'",
"ref": "'${{ github.ref }}'"
}'
- name: deploy score-humanitec
run: |
Expand Down
8 changes: 0 additions & 8 deletions score/humanitec.score.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
apiVersion: humanitec.org/v1b1
profile: humanitec/default-module
spec:
ingress:
rules:
"${resources.dns}":
http:
"/":
type: prefix
port: 8080
6 changes: 6 additions & 0 deletions score/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ containers:
resources:
dns:
type: dns
route:
type: route
params:
host: ${resources.dns.host}
path: /
port: 8080
service:
ports:
tcp:
Expand Down

0 comments on commit 4b823b6

Please sign in to comment.