|
| 1 | +# Please do not edit this file. |
| 2 | +# More information under https://docs.ionos.space/docs/github-actions-customization/ |
| 3 | +# version: 2022-07-21 |
| 4 | + |
| 5 | +name: "Deploy Now: Deploy to IONOS" |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + version: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + project-id: |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + branch-id: |
| 17 | + required: true |
| 18 | + type: string |
| 19 | + deployment-ids: |
| 20 | + require: true |
| 21 | + type: string |
| 22 | + push: |
| 23 | + path: |
| 24 | + - ./.github/workflows/deploy-to-ionos.yaml |
| 25 | + |
| 26 | +concurrency: ${{ github.ref }} |
| 27 | + |
| 28 | +jobs: |
| 29 | + deploy-to-ionos: |
| 30 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 31 | + runs-on: ubuntu-latest |
| 32 | + permissions: |
| 33 | + actions: read |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + deployment-id: ${{ fromJson(inputs.deployment-ids) }} |
| 37 | + steps: |
| 38 | + - name: Update deployment status |
| 39 | + uses: ionos-deploy-now/project-action@v1 |
| 40 | + with: |
| 41 | + api-key: ${{ secrets.IONOS_API_KEY }} |
| 42 | + service-host: api-eu.ionos.space |
| 43 | + project-id: ${{ inputs.project-id }} |
| 44 | + branch-id: ${{ inputs.branch-id }} |
| 45 | + deployment-id: ${{ matrix.deployment-id }} |
| 46 | + action: update-status |
| 47 | + status: in_progress |
| 48 | + |
| 49 | + - name: Retrieve stored deployment |
| 50 | + uses: ionos-deploy-now/artifact-action@v1 |
| 51 | + with: |
| 52 | + api-key: ${{ secrets.IONOS_API_KEY }} |
| 53 | + service-host: api-eu.ionos.space |
| 54 | + project-id: ${{ inputs.project-id }} |
| 55 | + branch-id: ${{ inputs.branch-id }} |
| 56 | + version: ${{ inputs.version }} |
| 57 | + action: download |
| 58 | + |
| 59 | + - name: Fetch deployment info |
| 60 | + uses: ionos-deploy-now/project-action@v1 |
| 61 | + id: deployment |
| 62 | + with: |
| 63 | + api-key: ${{ secrets.IONOS_API_KEY }} |
| 64 | + service-host: api-eu.ionos.space |
| 65 | + project-id: ${{ inputs.project-id }} |
| 66 | + branch-id: ${{ inputs.branch-id }} |
| 67 | + deployment-id: ${{ matrix.deployment-id }} |
| 68 | + action: retrieve-info |
| 69 | + |
| 70 | + - name: Render templates |
| 71 | + uses: ionos-deploy-now/template-renderer-action@v2 |
| 72 | + id: template |
| 73 | + with: |
| 74 | + deployment-id: ${{ matrix.deployment-id }} |
| 75 | + data: "[${{ steps.deployment.outputs.template-variables }}, ${{ toJson(secrets) }}]" |
| 76 | + input-directory: deployment |
| 77 | + output-directory: deployment |
| 78 | + intermediate-data-file: deployment/.template-renderer-data |
| 79 | + |
| 80 | + - name: Render real site-url to all files |
| 81 | + run: | |
| 82 | + for file in `grep -rl 'https://IONOS_DEPLOY_NOW_SITE_URL' .`; do |
| 83 | + sed -i $file -e 's|https://IONOS_DEPLOY_NOW_SITE_URL|${{ fromJson(steps.deployment.outputs.info).site-url }}|g' |
| 84 | + done |
| 85 | +
|
| 86 | + - name: Render SSH user secret name |
| 87 | + run: echo SSH_USERNAME_SECRET=IONOS_DEPLOYMENT_`echo ${{ matrix.deployment-id }} | tr '[:lower:]' '[:upper:]' | tr '-' '_'`_SSH_USERNAME >> $GITHUB_ENV |
| 88 | + |
| 89 | + - name: Deploy to IONOS |
| 90 | + uses: ionos-deploy-now/deploy-to-ionos-action@v2 |
| 91 | + with: |
| 92 | + api-key: ${{ secrets.IONOS_API_KEY }} |
| 93 | + service-host: api-eu.ionos.space |
| 94 | + project-id: ${{ inputs.project-id }} |
| 95 | + branch-id: ${{ inputs.branch-id }} |
| 96 | + deployment-id: ${{ matrix.deployment-id }} |
| 97 | + deployment-info: ${{ steps.deployment.outputs.info }} |
| 98 | + ssh-user: ${{ secrets[env.SSH_USERNAME_SECRET] }} |
| 99 | + ssh-key: ${{ secrets.IONOS_SSH_KEY }} |
| 100 | + |
| 101 | + - name: Update deployment status |
| 102 | + if: ${{ always() }} |
| 103 | + uses: ionos-deploy-now/project-action@v1 |
| 104 | + with: |
| 105 | + api-key: ${{ secrets.IONOS_API_KEY }} |
| 106 | + service-host: api-eu.ionos.space |
| 107 | + project-id: ${{ inputs.project-id }} |
| 108 | + branch-id: ${{ inputs.branch-id }} |
| 109 | + deployment-id: ${{ matrix.deployment-id }} |
| 110 | + action: update-status |
| 111 | + status: ${{ job.status }} |
| 112 | + |
| 113 | + notify-deployment-finished: |
| 114 | + needs: deploy-to-ionos |
| 115 | + if: ${{ github.event_name == 'workflow_dispatch' && always() }} |
| 116 | + runs-on: ubuntu-latest |
| 117 | + steps: |
| 118 | + - name: Notify all deployments finished |
| 119 | + uses: ionos-deploy-now/project-action@v1 |
| 120 | + with: |
| 121 | + api-key: ${{ secrets.IONOS_API_KEY }} |
| 122 | + service-host: api-eu.ionos.space |
| 123 | + project-id: ${{ inputs.project-id }} |
| 124 | + branch-id: ${{ inputs.branch-id }} |
| 125 | + action: set-deployments-finished |
0 commit comments