Skip to content

Commit

Permalink
More about humctl score deploy (#110)
Browse files Browse the repository at this point in the history
* HUMCTL_VERSION: '0.19.1'

* humctl score validate

* validate --strict

* humctl score deploy

* No score output anymore

* --deploy-config

* score.deploy.yaml

* --artefact-name

* artefact-name in score.deploy.yaml

* push tag with humctl score deploy

* No need of score-humanitec anymore

* humctl score deploy in docs
  • Loading branch information
mathieu-benoit authored Mar 29, 2024
1 parent 541d60c commit fd87202
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 57 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/open-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ env:
IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/${{ vars.APP_NAME }}
SCORE_COMPOSE_VERSION: 'latest'
SCORE_HELM_VERSION: 'latest'
SCORE_HUMANITEC_VERSION: 'latest'
WORKLOAD_NAME: my-sample-app
HUMCTL_VERSION: '0.19.1'
jobs:
Expand Down Expand Up @@ -174,17 +173,10 @@ jobs:
echo "IMAGE_DIGEST=$(oras manifest fetch ${{ env.IMAGE_NAME }}:${{ env.ENVIRONMENT_ID }} \
--descriptor \
| jq -r .digest)" >> ${{ github.env }}
- name: install score-humanitec
uses: score-spec/setup-score@v2
with:
file: score-humanitec
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.SCORE_HUMANITEC_VERSION }}
- name: humctl score deploy
run: |
HUMANITEC_CLI_ALPHA_FEATURES=score-deploy humctl score deploy \
-f score/score.yaml \
--extensions score/humanitec.score.yaml \
--deploy-config score/score.deploy.yaml \
--image ${{ env.IMAGE_NAME }}@${IMAGE_DIGEST} \
--message "$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.event.pull_request.commits_url }}?per_page=10" | jq -r .[-1].commit.message)" \
--workload-source-url "https://github.com/${{ github.repository }}/blob/${{ github.head_ref }}/score/score.yaml" \
Expand Down
57 changes: 13 additions & 44 deletions .github/workflows/push-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
IMAGE_TAG: ${{ github.ref_name }}
IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-app
ENVIRONMENT_ID: development
SCORE_HUMANITEC_VERSION: 'latest'
WORKLOAD_NAME: my-sample-app
HUMCTL_VERSION: '0.19.1'
jobs:
Expand Down Expand Up @@ -76,12 +75,6 @@ jobs:
--org ${{ secrets.HUMANITEC_ORG }} \
--name ${{ vars.APP_NAME }} \
|| true
- name: install score-humanitec
uses: score-spec/setup-score@v2
with:
file: score-humanitec
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ env.SCORE_HUMANITEC_VERSION }}
- name: authenticate to google cloud
uses: google-github-actions/auth@v2
with:
Expand Down Expand Up @@ -112,53 +105,29 @@ jobs:
--ref ${{ github.ref }} \
--commit $(echo ${{ github.sha }} | cut -c1-7) \
--digest ${IMAGE_DIGEST}
- name: deploy score-humanitec
- name: humctl score deploy
run: |
score-humanitec delta \
--retry \
--deploy \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} \
--env ${{ env.ENVIRONMENT_ID }} \
-f score/score.yaml \
--extensions score/humanitec.score.yaml \
--message ${{ github.ref_name }} \
HUMANITEC_CLI_ALPHA_FEATURES=score-deploy humctl score deploy \
--artefact-name ${{ vars.APP_NAME }}-${{ env.WORKLOAD_NAME }} \
--deploy-config score/score.deploy.yaml \
--image ${{ env.IMAGE_NAME }}@${IMAGE_DIGEST} \
--message ${{ github.ref_name }} \
--workload-source-url "https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/score/score.yaml" \
| tee score_output.json
- name: wait for deployment
run: |
sleep 1
IS_DONE=false
CURRENT_STATUS=""
while [ "$IS_DONE" = false ]; do
CURRENT_STATUS=$(humctl get deployment . -o json \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} \
--env ${{ env.ENVIRONMENT_ID }} \
| jq -r .status.status)
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 successfully completed!"
IS_DONE=true
fi
done
echo $CURRENT_STATUS
if [ "$CURRENT_STATUS" = "failed" ]; then
exit 1
fi
--wait
- name: get deployment information
if: ${{ always() }}
run: |
ENV_URL=$(jq -r ".metadata.url" score_output.json)
DEPLOYMENT_ID=$(jq -r ".id" score_output.json)
DEPLOYMENT_ID=$(humctl get deployment . -o json \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
--app ${{ vars.APP_NAME }} \
--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}
DOMAINS=$(humctl get active-resources \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ secrets.HUMANITEC_ORG }} \
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ kubectl apply \

Deploy the pre-built container with Score/Humanitec:
```bash
score-humanitec delta \
--retry \
--deploy \
humctl score deploy \
--token ${HUMANITEC_TOKEN} \
--org ${HUMANITEC_ORG} \
--app ${APP_ID} \
--env ${ENVIRONMENT_ID} \
-f score/score.yaml \
-i ghcr.io/mathieu-benoit/my-sample-app:latest
-i ghcr.io/mathieu-benoit/my-sample-app:latest \
--wait
```

## Build and test the application locally
Expand Down
4 changes: 4 additions & 0 deletions score/score.deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
workloads:
- name: my-sample-app/my-sample-app
specFile: ./score.yaml
extensionsFile: ./humanitec.score.yaml

0 comments on commit fd87202

Please sign in to comment.