From 871c6515e87ee88ed050aa6dade47683890f57c6 Mon Sep 17 00:00:00 2001 From: "ionos-deploy-now[bot]" <78917126+ionos-deploy-now[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:07:17 +0000 Subject: [PATCH] Add IONOS Deploy Now workflow --- .github/workflows/deploy-to-ionos.yaml | 125 ++++++++++++++++++ .github/workflows/rsv-dossier-build.yaml | 2 +- .../workflows/rsv-dossier-orchestration.yaml | 4 +- 3 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy-to-ionos.yaml diff --git a/.github/workflows/deploy-to-ionos.yaml b/.github/workflows/deploy-to-ionos.yaml new file mode 100644 index 0000000..f27b685 --- /dev/null +++ b/.github/workflows/deploy-to-ionos.yaml @@ -0,0 +1,125 @@ +# Please do not edit this file. +# More information under https://docs.ionos.space/docs/github-actions-customization/ +# version: 2022-07-21 + +name: "Deploy Now: Deploy to IONOS" + +on: + workflow_dispatch: + inputs: + version: + required: true + type: string + project-id: + required: true + type: string + branch-id: + required: true + type: string + deployment-ids: + require: true + type: string + push: + path: + - ./.github/workflows/deploy-to-ionos.yaml + +concurrency: ${{ github.ref }} + +jobs: + deploy-to-ionos: + if: ${{ github.event_name == 'workflow_dispatch' }} + runs-on: ubuntu-latest + permissions: + actions: read + strategy: + matrix: + deployment-id: ${{ fromJson(inputs.deployment-ids) }} + steps: + - name: Update deployment status + uses: ionos-deploy-now/project-action@v1 + with: + api-key: ${{ secrets.IONOS_API_KEY }} + service-host: api-eu.ionos.space + project-id: ${{ inputs.project-id }} + branch-id: ${{ inputs.branch-id }} + deployment-id: ${{ matrix.deployment-id }} + action: update-status + status: in_progress + + - name: Retrieve stored deployment + uses: ionos-deploy-now/artifact-action@v1 + with: + api-key: ${{ secrets.IONOS_API_KEY }} + service-host: api-eu.ionos.space + project-id: ${{ inputs.project-id }} + branch-id: ${{ inputs.branch-id }} + version: ${{ inputs.version }} + action: download + + - name: Fetch deployment info + uses: ionos-deploy-now/project-action@v1 + id: deployment + with: + api-key: ${{ secrets.IONOS_API_KEY }} + service-host: api-eu.ionos.space + project-id: ${{ inputs.project-id }} + branch-id: ${{ inputs.branch-id }} + deployment-id: ${{ matrix.deployment-id }} + action: retrieve-info + + - name: Render templates + uses: ionos-deploy-now/template-renderer-action@v2 + id: template + with: + deployment-id: ${{ matrix.deployment-id }} + data: "[${{ steps.deployment.outputs.template-variables }}, ${{ toJson(secrets) }}]" + input-directory: deployment + output-directory: deployment + intermediate-data-file: deployment/.template-renderer-data + + - name: Render real site-url to all files + run: | + for file in `grep -rl 'https://IONOS_DEPLOY_NOW_SITE_URL' .`; do + sed -i $file -e 's|https://IONOS_DEPLOY_NOW_SITE_URL|${{ fromJson(steps.deployment.outputs.info).site-url }}|g' + done + + - name: Render SSH user secret name + run: echo SSH_USERNAME_SECRET=IONOS_DEPLOYMENT_`echo ${{ matrix.deployment-id }} | tr '[:lower:]' '[:upper:]' | tr '-' '_'`_SSH_USERNAME >> $GITHUB_ENV + + - name: Deploy to IONOS + uses: ionos-deploy-now/deploy-to-ionos-action@v2 + with: + api-key: ${{ secrets.IONOS_API_KEY }} + service-host: api-eu.ionos.space + project-id: ${{ inputs.project-id }} + branch-id: ${{ inputs.branch-id }} + deployment-id: ${{ matrix.deployment-id }} + deployment-info: ${{ steps.deployment.outputs.info }} + ssh-user: ${{ secrets[env.SSH_USERNAME_SECRET] }} + ssh-key: ${{ secrets.IONOS_SSH_KEY }} + + - name: Update deployment status + if: ${{ always() }} + uses: ionos-deploy-now/project-action@v1 + with: + api-key: ${{ secrets.IONOS_API_KEY }} + service-host: api-eu.ionos.space + project-id: ${{ inputs.project-id }} + branch-id: ${{ inputs.branch-id }} + deployment-id: ${{ matrix.deployment-id }} + action: update-status + status: ${{ job.status }} + + notify-deployment-finished: + needs: deploy-to-ionos + if: ${{ github.event_name == 'workflow_dispatch' && always() }} + runs-on: ubuntu-latest + steps: + - name: Notify all deployments finished + uses: ionos-deploy-now/project-action@v1 + with: + api-key: ${{ secrets.IONOS_API_KEY }} + service-host: api-eu.ionos.space + project-id: ${{ inputs.project-id }} + branch-id: ${{ inputs.branch-id }} + action: set-deployments-finished diff --git a/.github/workflows/rsv-dossier-build.yaml b/.github/workflows/rsv-dossier-build.yaml index b54dd76..696f109 100644 --- a/.github/workflows/rsv-dossier-build.yaml +++ b/.github/workflows/rsv-dossier-build.yaml @@ -46,7 +46,7 @@ jobs: with: api-key: ${{ secrets.IONOS_API_KEY }} service-host: api-eu.ionos.space - project-id: 47f75248-c169-4fc1-b9fe-0010e1cfa65f + project-id: a64d7de8-7959-4d90-85c1-77ebe089fe46 branch-id: ${{ inputs.branch-id }} version: ${{ github.sha }} folder: ${{ env.DEPLOYMENT_FOLDER }} diff --git a/.github/workflows/rsv-dossier-orchestration.yaml b/.github/workflows/rsv-dossier-orchestration.yaml index 06e4b17..8a4b3ed 100644 --- a/.github/workflows/rsv-dossier-orchestration.yaml +++ b/.github/workflows/rsv-dossier-orchestration.yaml @@ -24,7 +24,7 @@ jobs: with: api-key: ${{ secrets.IONOS_API_KEY }} service-host: api-eu.ionos.space - project-id: 47f75248-c169-4fc1-b9fe-0010e1cfa65f + project-id: a64d7de8-7959-4d90-85c1-77ebe089fe46 action: retrieve-info @@ -50,6 +50,6 @@ jobs: with: api-key: ${{ secrets.IONOS_API_KEY }} service-host: api-eu.ionos.space - project-id: 47f75248-c169-4fc1-b9fe-0010e1cfa65f + project-id: a64d7de8-7959-4d90-85c1-77ebe089fe46 branch-id: ${{ needs.retrieve-project.outputs.branch-id }} action: dispatch-deployments