Skip to content

Commit

Permalink
humctl score deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-benoit authored Apr 15, 2024
1 parent bda68ad commit 19ca317
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 100 deletions.
43 changes: 19 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,31 @@ jobs:
run: |
mkdir credentials && touch credentials/github-app-backstage-humanitec-credentials.yaml
docker image build -t backstage:latest .
score-humanitec:
score-validate:
runs-on: ubuntu-latest
env:
SCORE_HUMANITEC_VERSION: '0.10.1'
HUMCTL_VERSION: '0.21.0'
steps:
- name: checkout code
uses: actions/checkout@v3
- name: install score-humanitec
uses: score-spec/setup-score@v2
- uses: humanitec/setup-cli-action@v1
with:
file: score-humanitec
version: ${{ env.SCORE_HUMANITEC_VERSION }}
- name: score-humanitec run - backstage
version: ${{ env.HUMCTL_VERSION }}
- name: humctl score validate - backstage
run: |
score-humanitec run \
--env development \
-f score.yaml \
--extensions humanitec.score.yaml \
--image backstage:latest
- name: score-humanitec run - node-service
humctl score validate score.yaml \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--strict
- name: humctl score validate - node-service
run: |
score-humanitec run \
--env development \
-f templates/node-service/content/score.yaml \
--extensions templates/node-service/content/humanitec.score.yaml \
--image node-service:latest
- name: score-humanitec run - podinfo
humctl score validate templates/node-service/content/score.yaml \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--strict
- name: humctl score validate - podinfo
run: |
score-humanitec run \
--env development \
-f templates/podinfo-example/content/score.yaml \
--extensions templates/podinfo-example/content/humanitec.score.yaml \
--image podinfo:latest
humctl score validate templates/podinfo-example/content/score.yaml \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--strict
12 changes: 2 additions & 10 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ concurrency: ${{ github.ref }}

env:
IMAGE: backstage
SCORE_HUMANITEC_VERSION: '0.10.2'
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'
# CLOUD_PROVIDER: aws
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_ROLE_ARN: ${{ vars.AWS_ROLE_ARN }}
Expand Down Expand Up @@ -127,16 +126,9 @@ jobs:
--ref $GITHUB_REF \
--commit $GITHUB_SHA
- uses: score-spec/setup-score@v2
with:
file: score-humanitec
version: ${{ env.SCORE_HUMANITEC_VERSION }}

- name: Run Score
run: |
score-humanitec delta \
--retry \
--deploy \
humctl score deploy \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--app backstage \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
APP_NAME: ${{ values.name }}
ENVIRONMENT_ID: {% raw %}pr-${{ github.event.number }}{% endraw %}
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'

{% raw %}
jobs:
Expand Down
12 changes: 2 additions & 10 deletions templates/node-service/content/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ env:
{%- else -%}
# Unknown cloud provider: ${{ values.cloudProvider }}
{% endif %}
SCORE_HUMANITEC_VERSION: '0.10.2'
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'
APP_NAME: ${{ values.name }}

{% raw %}
Expand Down Expand Up @@ -116,16 +115,9 @@ jobs:
--ref $GITHUB_REF \
--commit $GITHUB_SHA
- uses: score-spec/setup-score@v2
with:
file: score-humanitec
version: ${{ env.SCORE_HUMANITEC_VERSION }}

- name: Deploy using Score
run: |
score-humanitec delta \
--retry \
--deploy \
humctl score deploy \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--app ${{ env.APP_NAME }} \
Expand Down
25 changes: 3 additions & 22 deletions templates/node-service/content/.github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ env:
{% endif %}
BASE_ENVIRONMENT: 'development'
ENVIRONMENT_TYPE: 'development'
SCORE_HUMANITEC_VERSION: '0.10.2'
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'
ENVIRONMENT_ID: {% raw %}pr-${{ github.event.number }}{% endraw %}
ENVIRONMENT_NAME: {% raw %}PR-${{ github.event.number }}{% endraw %}

Expand All @@ -60,10 +59,6 @@ jobs:
-t ${{ env.ENVIRONMENT_TYPE }} \
--from ${{ env.BASE_ENVIRONMENT }} \
|| true
- uses: score-spec/setup-score@v2
with:
file: score-humanitec
version: ${{ env.SCORE_HUMANITEC_VERSION }}
- name: Set Tag with SHA
run: echo "TAG=`echo $GITHUB_SHA | cut -c 1-7`" >> $GITHUB_ENV
{% endraw %}
Expand Down Expand Up @@ -132,9 +127,7 @@ jobs:
- name: Run Score
run: |
score-humanitec delta \
--retry \
--deploy \
humctl score deploy \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--app ${{ env.APP_NAME }} \
Expand All @@ -143,8 +136,7 @@ jobs:
--extensions humanitec.score.yaml \
--workload-source-url "https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/score.yaml" \
--image $CONTAINER_REGISTRY/$IMAGE:$TAG \
--message "$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.event.pull_request.commits_url }}?per_page=10" | jq -r .[-1].commit.message)" \
| tee score_output.json
--message "$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.event.pull_request.commits_url }}?per_page=10" | jq -r .[-1].commit.message)"
- name: Wait for deployment
run: |
sleep 1
Expand Down Expand Up @@ -279,17 +271,6 @@ jobs:
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt
fi
echo "<details><summary>Score Output</summary>" >> pr_message.txt
echo "" >> pr_message.txt
echo "### Score Output:" >> pr_message.txt
echo '```json' >> pr_message.txt
echo "" >> pr_message.txt
cat score_output.json >> pr_message.txt
echo "" >> pr_message.txt
echo '```' >> pr_message.txt
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt
cat pr_message.txt
- name: Comment PR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
APP_NAME: ${{ values.name }}
ENVIRONMENT_ID: {% raw %}pr-${{ github.event.number }}{% endraw %}
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'

{% raw %}
jobs:
Expand Down
12 changes: 2 additions & 10 deletions templates/podinfo-example/content/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ env:
{%- else -%}
# Unknown cloud provider: ${{ values.cloudProvider }}
{% endif %}
SCORE_HUMANITEC_VERSION: '0.10.2'
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'
APP_NAME: ${{ values.name }}

{% raw %}
Expand Down Expand Up @@ -116,16 +115,9 @@ jobs:
--ref $GITHUB_REF \
--commit $GITHUB_SHA
- uses: score-spec/setup-score@v2
with:
file: score-humanitec
version: ${{ env.SCORE_HUMANITEC_VERSION }}

- name: Deploy using Score
run: |
score-humanitec delta \
--retry \
--deploy \
humctl score deploy \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--app ${{ env.APP_NAME }} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ env:
{% endif %}
BASE_ENVIRONMENT: 'development'
ENVIRONMENT_TYPE: 'development'
SCORE_HUMANITEC_VERSION: '0.10.2'
HUMCTL_VERSION: '0.15.0'
HUMCTL_VERSION: '0.21.0'
ENVIRONMENT_ID: {% raw %}pr-${{ github.event.number }}{% endraw %}
ENVIRONMENT_NAME: {% raw %}PR-${{ github.event.number }}{% endraw %}

Expand All @@ -60,10 +59,6 @@ jobs:
-t ${{ env.ENVIRONMENT_TYPE }} \
--from ${{ env.BASE_ENVIRONMENT }} \
|| true
- uses: score-spec/setup-score@v2
with:
file: score-humanitec
version: ${{ env.SCORE_HUMANITEC_VERSION }}
- name: Set Tag with SHA
run: echo "TAG=`echo $GITHUB_SHA | cut -c 1-7`" >> $GITHUB_ENV
{% endraw %}
Expand Down Expand Up @@ -132,9 +127,7 @@ jobs:
- name: Run Score
run: |
score-humanitec delta \
--retry \
--deploy \
humctl score deploy \
--token ${{ secrets.HUMANITEC_TOKEN }} \
--org ${{ vars.HUMANITEC_ORG_ID }} \
--app ${{ env.APP_NAME }} \
Expand All @@ -143,8 +136,7 @@ jobs:
--extensions humanitec.score.yaml \
--workload-source-url "https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/score.yaml" \
--image $CONTAINER_REGISTRY/$IMAGE:$TAG \
--message "$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.event.pull_request.commits_url }}?per_page=10" | jq -r .[-1].commit.message)" \
| tee score_output.json
--message "$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.event.pull_request.commits_url }}?per_page=10" | jq -r .[-1].commit.message)"
- name: Wait for deployment
run: |
sleep 1
Expand Down Expand Up @@ -279,17 +271,6 @@ jobs:
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt
fi
echo "<details><summary>Score Output</summary>" >> pr_message.txt
echo "" >> pr_message.txt
echo "### Score Output:" >> pr_message.txt
echo '```json' >> pr_message.txt
echo "" >> pr_message.txt
cat score_output.json >> pr_message.txt
echo "" >> pr_message.txt
echo '```' >> pr_message.txt
echo "" >> pr_message.txt
echo "</details>" >> pr_message.txt
cat pr_message.txt
- name: Comment PR
Expand Down

0 comments on commit 19ca317

Please sign in to comment.