Skip to content

Update score.yaml

Update score.yaml #4

Workflow file for this run

name: Pull Request
on:
pull_request:
types: [opened, reopened, synchronize]
permissions:
contents: read
pull-requests: write
env:
BASE_ENVIRONMENT: 'development'
ENVIRONMENT_TYPE: 'ephemeral'
HUMCTL_VERSION: 0.24.0
ENVIRONMENT_ID: pr-${{ github.event.number }}
ENVIRONMENT_NAME: PR-${{ github.event.number }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Push to Humanitec
id: build-push
uses: humanitec/build-push-to-humanitec@v1
with:
humanitec-token: ${{ secrets.HUMANITEC_TOKEN }}
organization: ${{ vars.HUMANITEC_ORG }}
- name: Install humctl
run: |
wget https://github.com/humanitec/cli/releases/download/v${{ env.HUMCTL_VERSION }}/cli_${{ env.HUMCTL_VERSION }}_linux_amd64.tar.gz
tar -xvf cli_${{ env.HUMCTL_VERSION }}_linux_amd64.tar.gz
chmod +x humctl
mv humctl /usr/local/bin
- name: Create Humanitec Env
run: |
# Check in case this PR receives additional pushes
if humctl get env "${{ env.ENVIRONMENT_ID }}" \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG }} \
--app ${{ vars.HUMANITEC_APP }}
then
echo "Environment ${{ env.ENVIRONMENT_ID }} already exists. Skipping creation."
exit
fi
humctl create env "${{ env.ENVIRONMENT_ID }}" \
--name "${{ env.ENVIRONMENT_NAME }}" \
--type "${{ env.ENVIRONMENT_TYPE }}" \
--from "${{ env.BASE_ENVIRONMENT }}" \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG }} \
--app ${{ vars.HUMANITEC_APP }}
- name: Run Score
run: |
if ! [ -f score.yaml ]
then
echo "no score file found, cannot deploy"
exit 1
fi
humctl score deploy -f score.yaml \
--image "${{ steps.build-push.outputs.image }}" \
--wait \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG }} \
--app ${{ vars.HUMANITEC_APP }} \
--env ${{ env.ENVIRONMENT_ID }}
- name: Wait for deployment
run: |
sleep 1
IS_DONE=false
while [ "$IS_DONE" = false ]; do
CURRENT_STATUS="$(humctl get env "${{ env.ENVIRONMENT_ID }}" \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG }} \
--app ${{ vars.HUMANITEC_APP }} \
-o json | jq -r ".status.last_deploy.status.status")"
INPROGRESS="in progress"
if [ "$CURRENT_STATUS" = "$INPROGRESS" ]; then
echo "Deployment still in progress..."
sleep 1
else
echo "Deployment complete!"
IS_DONE=true
fi
done
- name: Build Comment Message
run: |
DOMAINS="$(humctl get active-resources \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG }} \
--app ${{ vars.HUMANITEC_APP }} \
--env ${{ env.ENVIRONMENT_ID }} \
-o json | jq -r '[.[] | select(.metadata.type == "dns") | (.metadata.res_id | split(".") | .[1]) + ": [" + .status.resource.host + "](https://" + .status.resource.host+ ")"] | join("\n")')"
echo "## Deployment Complete for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt
echo "" >> pr_message.txt
echo "### [View in Humanitec](https://app.humanitec.io/orgs/${{ vars.HUMANITEC_ORG }}/apps/${{ vars.HUMANITEC_APP }})/envs/${{ env.ENVIRONMENT_ID }}" >> pr_message.txt
echo "" >> pr_message.txt
echo "### Domains:" >> pr_message.txt
echo "" >> pr_message.txt
echo "$DOMAINS" >> pr_message.txt
echo "" >> pr_message.txt
cat pr_message.txt
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
filePath: pr_message.txt