From 8cbdd1f650e071180982b05c7b8c37f77cb5a60e Mon Sep 17 00:00:00 2001 From: Giovanni Barbaro Date: Wed, 26 Feb 2025 10:40:02 +0100 Subject: [PATCH 1/3] Adds automation for deploying acceptance and production --- .github/workflows/deploy_acceptance.yaml | 12 ++++++++ .github/workflows/deploy_production.yaml | 12 ++++++++ .github/workflows/deploy_template.yaml | 38 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 .github/workflows/deploy_acceptance.yaml create mode 100644 .github/workflows/deploy_production.yaml create mode 100644 .github/workflows/deploy_template.yaml diff --git a/.github/workflows/deploy_acceptance.yaml b/.github/workflows/deploy_acceptance.yaml new file mode 100644 index 0000000..06aa97d --- /dev/null +++ b/.github/workflows/deploy_acceptance.yaml @@ -0,0 +1,12 @@ +name: Deploy Acceptance + +on: + workflow_dispatch: {} + +jobs: + deploy_acceptance: + uses: ./.github/workflows/deploy_template.yaml + with: + target_branch: 'acceptance' + source_branch: 'main' + secrets: inherit diff --git a/.github/workflows/deploy_production.yaml b/.github/workflows/deploy_production.yaml new file mode 100644 index 0000000..bfed44b --- /dev/null +++ b/.github/workflows/deploy_production.yaml @@ -0,0 +1,12 @@ +name: Deploy Production + +on: + workflow_dispatch: {} + +jobs: + deploy_acceptance: + uses: ./.github/workflows/deploy_template.yaml + with: + target_branch: 'production' + source_branch: 'acceptance' + secrets: inherit diff --git a/.github/workflows/deploy_template.yaml b/.github/workflows/deploy_template.yaml new file mode 100644 index 0000000..f7a9b87 --- /dev/null +++ b/.github/workflows/deploy_template.yaml @@ -0,0 +1,38 @@ +name: Deploy Template + +on: + workflow_call: + inputs: + source_branch: + type: string + required: true + description: Source Branch + target_branch: + type: string + required: true + description: Target Branch +jobs: + deploy: + name: Deploy ${{ inputs.target_branch }} + runs-on: ubuntu-latest + steps: + - uses: actions/create-github-app-token@v1 + name: Generate GitHub Token + id: app-token + with: + app-id: ${{ secrets.LUNATECH_BLOG_APP_ID }} + private-key: ${{ secrets.LUNATECH_BLOG_APP_PRIVATE_KEY }} + + - uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + fetch-depth: '0' + + - name: Merge from ${{ inputs.source_branch }} to ${{ inputs.target_branch }} + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + git fetch origin + git checkout ${{ inputs.target_branch }} + git rebase origin/${{ inputs.source_branch }} + git push origin ${{ inputs.target_branch }} From 2aad46a9f689cae6e82f25c4b6645aecefd1b3b8 Mon Sep 17 00:00:00 2001 From: Giovanni Barbaro Date: Fri, 28 Feb 2025 10:10:28 +0100 Subject: [PATCH 2/3] Adds README docs --- .github/workflows/deploy_template.yaml | 2 -- README.md | 13 +++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_template.yaml b/.github/workflows/deploy_template.yaml index f7a9b87..8839cc5 100644 --- a/.github/workflows/deploy_template.yaml +++ b/.github/workflows/deploy_template.yaml @@ -29,8 +29,6 @@ jobs: fetch-depth: '0' - name: Merge from ${{ inputs.source_branch }} to ${{ inputs.target_branch }} - env: - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} run: | git fetch origin git checkout ${{ inputs.target_branch }} diff --git a/README.md b/README.md index 55ff0a9..6066e7b 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,16 @@ You can modify the template in the `app/views/` directory. ## Starting the application `sbt run` and go in your browser to `http:localhost:9000` + +# How to deploy a new version + +Merging your PR will update the `main` branch only. You'll need to deploy it first in +[Acceptance](https://blog.acceptance.lunatech.com/), and then in [Production](https://blog.lunatech.com/). + +You can do both with the help of GitHub Actions: +* [Deploy Acceptance](https://github.com/lunatech-labs/lunatech-blog-engine/actions/workflows/deploy_acceptance.yaml) +* [Deploy Production](https://github.com/lunatech-labs/lunatech-blog-engine/actions/workflows/deploy_production.yaml) + +For the time being, the blog engine needs to be manually restarted in clever cloud as well. Please ask your colleagues +if you don't know how to do that. + From 4cda7acaa6be9d1e22041319d56ca82dd5b95742 Mon Sep 17 00:00:00 2001 From: Giovanni Barbaro Date: Fri, 28 Feb 2025 10:53:27 +0100 Subject: [PATCH 3/3] Removes restart requirement --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 6066e7b..3b480e6 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,4 @@ You can do both with the help of GitHub Actions: * [Deploy Acceptance](https://github.com/lunatech-labs/lunatech-blog-engine/actions/workflows/deploy_acceptance.yaml) * [Deploy Production](https://github.com/lunatech-labs/lunatech-blog-engine/actions/workflows/deploy_production.yaml) -For the time being, the blog engine needs to be manually restarted in clever cloud as well. Please ask your colleagues -if you don't know how to do that.