jcloudify: deployment ID: a113260f-73a5-4e61-a723-c7fd9553d3fb #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD Compute | |
on: | |
push: | |
branches: | |
- "preprod" | |
- "prod" | |
workflow_dispatch: | |
jobs: | |
initiate-deployment: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
env: | |
AWS_REGION: eu-west-3 | |
steps: | |
- uses: actions/[email protected] | |
- name: Update github workflow state | |
run: | | |
commit_message=$(git log -1 --pretty=%B) | |
commit_author=$(git log -1 --pretty=%an) | |
app_env_deployment_id_value=${{ env.app_env_deployment_id }} | |
if [ -z "$app_env_deployment_id_value" ]; then | |
app_env_deployment_id_value=null | |
else | |
app_env_deployment_id_value="\"$app_env_deployment_id_value\"" | |
fi | |
response=$(curl --fail -X POST "https://api.prod.jcloudify.com/gh-repos/${{ github.repository }}/github-workflow-state" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"app_env_deployment_id\":$app_env_deployment_id_value, \"commit_sha\":\"${{ github.sha }}\", \"commit_message\":$(echo \"$commit_message\"), \"commit_author_name\":$(echo \"$commit_author\"), \"status\":\"WORKFLOW_RUNNING\", \"environment_type\":$(echo \"${{ github.ref_name }}\" | tr \"[:lower:]\" \'[:upper:]\")}") | |
echo "app_env_deployment_id=$(echo $response | jq -r '.app_env_deployment_id')" >> $GITHUB_ENV | |
echo $response | |
- uses: actions/[email protected] | |
with: | |
java-version: '21' | |
distribution: 'corretto' | |
- name: Prepare build | |
run: | | |
chmod +x ./gradlew | |
chmod +x .shell/publish_gen_to_maven_local.sh | |
response=$(curl -X GET "https://api.prod.jcloudify.com/gh-repos/${{ github.repository }}/upload-build-uri?environment_type=$(echo "${{ github.ref_name }}" | tr '[:lower:]' '[:upper:]')" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/json") | |
echo "upload_build_file_uri=$(echo $response | jq -r '.uri')" >> $GITHUB_ENV | |
echo "to_upload_filename=$(echo $response | jq -r '.filename')" >> $GITHUB_ENV | |
curl -X GET -o template.yml "$(echo $response | jq -r '.build_template_file_uri')" | |
- name: Build project | |
run: sam build | |
- name: Prepare JCloudify deployment | |
run: | | |
shopt -s globstar | |
zip -r9 ${{ env.to_upload_filename }} .aws-sam | |
shopt -u globstar | |
curl -X PUT -H "Content-Type: application/zip" -T ${{ env.to_upload_filename }} "${{ env.upload_build_file_uri }}" | |
- name: Get current time | |
uses: gerred/actions/current-time@master | |
id: current-time | |
- name: Create UUID | |
id: generate-uuid | |
uses: filipstefansson/uuid-action@v1 | |
with: | |
name: ${{ steps.current-time.outputs.time }} | |
- name: Trigger JCloudify deployment | |
run: | | |
curl --fail -X PUT "https://api.prod.jcloudify.com/gh-repos/${{ github.repository }}/env-deploys?environment_type=$(echo "${{ github.ref_name }}" | tr '[:lower:]' '[:upper:]')" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"formatted_bucket_key\":\"${{ env.to_upload_filename }}\",\"id\":\"${{ steps.generate-uuid.outputs.uuid }}\", \"commit_sha\":\"${{ github.sha }}\", \"app_env_deployment_id\":\"${{ env.app_env_deployment_id }}\", \"environment_type\":$(echo \"${{ github.ref_name }}\" | tr \"[:lower:]\" \'[:upper:]\")}" | |
- name: Update github state if step fails | |
if: failure() | |
run: | | |
app_env_deployment_id_value=${{ env.app_env_deployment_id }} | |
if [ -z "$app_env_deployment_id_value" ]; then | |
app_env_deployment_id_value=null | |
else | |
app_env_deployment_id_value="\"$app_env_deployment_id_value\"" | |
fi | |
curl -X POST "https://api.prod.jcloudify.com/gh-repos/${{ github.repository }}/github-workflow-state" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"app_env_deployment_id\":$app_env_deployment_id_value, \"commit_sha\":\"${{ github.sha }}\", \"commit_message\":$(echo \"$commit_message\"), \"commit_author_name\":$(echo \"$commit_author\"), \"status\":\"WORKFLOW_FAILED\", \"environment_type\":$(echo \"${{ github.ref_name }}\" | tr \"[:lower:]\" \'[:upper:]\")}" |