Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve comment in PR (with new Graph URL) + token to install humctl #161

Merged
merged 10 commits into from
Dec 12, 2024
1 change: 1 addition & 0 deletions .github/workflows/close-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: install humctl
uses: humanitec/setup-cli-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.HUMCTL_VERSION }}
- name: delete humanitec env
run: |
Expand Down
34 changes: 9 additions & 25 deletions .github/workflows/open-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- name: install humctl
uses: humanitec/setup-cli-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.HUMCTL_VERSION }}
- name: humctl score validate
run: |
Expand Down Expand Up @@ -112,6 +113,7 @@ jobs:
- name: install humctl
uses: humanitec/setup-cli-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.HUMCTL_VERSION }}
- name: create humanitec preview env
run: |
Expand Down Expand Up @@ -173,12 +175,13 @@ jobs:
--env ${{ env.ENVIRONMENT_ID }} \
| jq -r .metadata.id)
ENV_URL="https://app.humanitec.io/orgs/"${{ secrets.HUMANITEC_ORG }}"/apps/"${{ vars.APP_NAME }}"/envs/"${{ env.ENVIRONMENT_ID }}"/deploys/"${DEPLOYMENT_ID}
GRAPH_URL="https://app.humanitec.io/orgs/"${{ secrets.HUMANITEC_ORG }}"/apps/"${{ vars.APP_NAME }}"/envs/"${{ env.ENVIRONMENT_ID }}"/resource-graph/"${DEPLOYMENT_ID}
DOMAINS=$(humctl get active-resources \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} \
--env ${{ env.ENVIRONMENT_ID }} -o json \
| jq -r '. | map(. | select(.metadata.type == "dns")) | map((.metadata.res_id | split(".") | .[1]) + ": [" + .status.resource.host + "](https://" + .status.resource.host + ")") | join("\n")')
| jq -r '. | map(. | select(.metadata.type == "dns")) | map(":link: " + (.metadata.res_id | split(".") | .[1]) + ": [" + .status.resource.host + "](https://" + .status.resource.host + ")") | join("\n")')

DEPLOYMENT_ERRORS=$(humctl get deployment-error \
--token ${{ secrets.HUMANITEC_TOKEN }} \
Expand Down Expand Up @@ -225,12 +228,10 @@ jobs:
echo "" >> pr_message.txt
fi
fi

echo "### [View in Humanitec]($ENV_URL)" >> pr_message.txt
echo "Deployment ID: $DEPLOYMENT_ID" >> pr_message.txt

echo "" >> pr_message.txt
echo "### URLs:" >> pr_message.txt
echo "### :arrow_right: [Open Resource Graph]($GRAPH_URL)" >> pr_message.txt
echo "### :mag: [View Deployment in Humanitec]($ENV_URL)" >> pr_message.txt

echo "" >> pr_message.txt
echo "$DOMAINS" >> pr_message.txt
echo "" >> pr_message.txt
Expand Down Expand Up @@ -276,36 +277,19 @@ jobs:
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} \
-o json | jq '.[] | [.metadata.type, .metadata.res_id, .status.class, .status.driver_type, .status.def_id, .status.resource]' > res-usage-${{ env.ENVIRONMENT_ID }}.txt
-o json | jq '.[] | [.metadata.type, .metadata.res_id, .status.class, .status.driver_type, .status.def_id, .status.def_version_id, .status.resource]' > res-usage-${{ env.ENVIRONMENT_ID }}.txt
humctl get active-resource \
--env ${{ env.BASE_ENVIRONMENT }} \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} \
-o json | jq '.[] | [.metadata.type, .metadata.res_id, .status.class, .status.driver_type, .status.def_id, .status.resource]' > res-usage-${{ env.BASE_ENVIRONMENT }}.txt
-o json | jq '.[] | [.metadata.type, .metadata.res_id, .status.class, .status.driver_type, .status.def_id, .status.def_version_id, .status.resource]' > res-usage-${{ env.BASE_ENVIRONMENT }}.txt
diff res-usage-${{ env.BASE_ENVIRONMENT }}.txt res-usage-${{ env.ENVIRONMENT_ID }}.txt >> pr_message.txt || true
echo "" >> pr_message.txt
echo '```' >> pr_message.txt
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt

if [ "$DEPLOYMENT_ERRORS" = "[]" ]; then
echo "<details><summary>Resources Graph</summary>" >> pr_message.txt
echo "" >> pr_message.txt
echo "### Resources Graph:" >> pr_message.txt
echo "Use a [Graphviz](https://graphviz.org) viewer for a visual representation." >> pr_message.txt
echo '```none' >> pr_message.txt
echo "" >> pr_message.txt
humctl resources graph \
--env ${{ env.ENVIRONMENT_ID }} \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} >> pr_message.txt
echo "" >> pr_message.txt
echo '```' >> pr_message.txt
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt
fi
- name: comment pr
if: ${{ always() }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/promote-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- name: install humctl
uses: humanitec/setup-cli-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.HUMCTL_VERSION }}
- name: promote humanitec env
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
- name: install humctl
uses: humanitec/setup-cli-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.HUMCTL_VERSION }}
- name: create humanitec app
run: |
Expand Down
2 changes: 0 additions & 2 deletions score/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ containers:
variables:
MESSAGE: "Hello, World!"
resources:
my-redis:
type: redis
dns:
type: dns
route:
Expand Down