From 74bcd5b8530d8ff2d1ec1ebc7b629132a0829c9b Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 20:36:35 +0100 Subject: [PATCH 01/10] adding github actions workflow to create release draft --- .github/workflows/quality-assurance.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index f8672bb..9db1eee 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -5,6 +5,7 @@ on: branches: - 'main' - 'bundestag-2025' + - 'github-actions-test' pull_request: types: [opened, synchronize, reopened, ready_for_review] From 3ee94d7d26ff2598f3064f77c53bee69fb22d262 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 20:41:42 +0100 Subject: [PATCH 02/10] now added workflows --- .github/workflows/deploy.yml | 40 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7b06c6b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,40 @@ +name: 3. Deploy to Azure + +on: + release: + types: + - published + +jobs: + deploy: + name: Deploy to Azure + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build Docker Image + run: | + docker build --platform linux/amd64 -t cliedl/electify:${{ github.event.release.tag_name }} . + + - name: Push Docker Image + run: | + docker push cliedl/electify:${{ github.event.release.tag_name }} + + - name: Log in to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy to Azure Container Apps + run: | + az containerapp update \ + --name electify \ + --resource-group electify-app \ + --image cliedl/electify:${{ github.event.release.tag_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a0e906c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: 2. Draft Release + +on: + push: + branches: + - github-actions-test + pull_request: + types: + - closed + branches: + - github-actions-test + +jobs: + draft_release: + name: Create Draft Release + needs: [quality, tests] + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.bump_version.outputs.new_version }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Fetch all tags + run: git fetch --tags + + - name: Determine Next Version + id: bump_version + run: | + LATEST_TAG=$(git tag --sort=-v:refname | head -n 1) + if [[ -z "$LATEST_TAG" ]]; then + NEW_VERSION="0.0.1" + else + IFS='.' read -r -a PARTS <<< "$LATEST_TAG" + NEW_VERSION="${PARTS[0]}.${PARTS[1]}.$((PARTS[2] + 1))" + fi + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Create Draft Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.NEW_VERSION }} + name: Release ${{ env.NEW_VERSION }} + body: "Automated draft release for version ${{ env.NEW_VERSION }}" + draft: true + prerelease: false From e13405eb02a82c66d7300ad66aa590359abc2944 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 20:47:03 +0100 Subject: [PATCH 03/10] removed dep on quality-assurance --- .github/workflows/deploy.yml | 8 ++++++++ .github/workflows/release.yml | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7b06c6b..eacbbea 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,10 +5,18 @@ on: types: - published + # enables manual triggers + workflow_dispatch: + inputs: + release_id: + description: 'Release tag id to be deployed' + required: true + type: string jobs: deploy: name: Deploy to Azure runs-on: ubuntu-latest + needs: [] steps: - name: Checkout Repository uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0e906c..c70980a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,10 +10,12 @@ on: branches: - github-actions-test + # enables manual triggers + workflow_dispatch: + jobs: draft_release: name: Create Draft Release - needs: [quality, tests] if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) runs-on: ubuntu-latest outputs: From 65e07eac5698d7a2085218bc6e7acfdfe57f0d4d Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 20:50:45 +0100 Subject: [PATCH 04/10] added github token --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c70980a..b94276d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,8 @@ on: jobs: draft_release: name: Create Draft Release + permissions: + contents: write if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) runs-on: ubuntu-latest outputs: @@ -25,7 +27,9 @@ jobs: uses: actions/checkout@v4 - name: Fetch all tags - run: git fetch --tags + run: | + git fetch --tags + echo "GH_TOKEN=${{ github.token }}" >> $GITHUB_ENV - name: Determine Next Version id: bump_version @@ -42,6 +46,8 @@ jobs: - name: Create Draft Release uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ github.token }} with: tag_name: ${{ env.NEW_VERSION }} name: Release ${{ env.NEW_VERSION }} From 5aed42e0193749a96a674d6195416d2f650fd979 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 20:53:23 +0100 Subject: [PATCH 05/10] removed test branch from trigger section --- .github/workflows/quality-assurance.yml | 2 -- .github/workflows/release.yml | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 9db1eee..2d2f0f7 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -4,8 +4,6 @@ on: push: branches: - 'main' - - 'bundestag-2025' - - 'github-actions-test' pull_request: types: [opened, synchronize, reopened, ready_for_review] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b94276d..294437e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,12 +3,12 @@ name: 2. Draft Release on: push: branches: - - github-actions-test + - main pull_request: types: - closed branches: - - github-actions-test + - main # enables manual triggers workflow_dispatch: From c0e031142bace944d82fbb1d20e8e865ccefb139 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 20:56:56 +0100 Subject: [PATCH 06/10] added line break --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index eacbbea..67bc59a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,6 +12,7 @@ on: description: 'Release tag id to be deployed' required: true type: string + jobs: deploy: name: Deploy to Azure From a8dfa2dfe6e559c897c87422974f70fdb27403c9 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 21:00:13 +0100 Subject: [PATCH 07/10] testing --- .github/workflows/deploy.yml | 12 ++++++------ .github/workflows/release.yml | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 67bc59a..b51aa2d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ name: 3. Deploy to Azure on: - release: - types: - - published + push: + branches: + - github-actions-test # enables manual triggers workflow_dispatch: @@ -30,11 +30,11 @@ jobs: - name: Build Docker Image run: | - docker build --platform linux/amd64 -t cliedl/electify:${{ github.event.release.tag_name }} . + docker build --platform linux/amd64 -t cliedl/electify:1.0.1 . - name: Push Docker Image run: | - docker push cliedl/electify:${{ github.event.release.tag_name }} + docker push cliedl/electify:1.0.1 - name: Log in to Azure uses: azure/login@v1 @@ -46,4 +46,4 @@ jobs: az containerapp update \ --name electify \ --resource-group electify-app \ - --image cliedl/electify:${{ github.event.release.tag_name }} + --image cliedl/electify:1.0.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 294437e..b3de4f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,7 @@ name: 2. Draft Release on: push: branches: + - github-actions-test - main pull_request: types: From e0c4ddbf5f838d4730a91cb2ce6bb11f14ed8078 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 21:18:53 +0100 Subject: [PATCH 08/10] testing --- .github/workflows/deploy.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b51aa2d..25e9cca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,20 +22,6 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build Docker Image - run: | - docker build --platform linux/amd64 -t cliedl/electify:1.0.1 . - - - name: Push Docker Image - run: | - docker push cliedl/electify:1.0.1 - - name: Log in to Azure uses: azure/login@v1 with: From 5358d3e8fcae4ba50a55c59290f85332ef9f23bb Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 21:35:56 +0100 Subject: [PATCH 09/10] fixed --- .github/workflows/deploy.yml | 50 ++++++++++++++++++++++++----------- .github/workflows/release.yml | 2 +- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 25e9cca..003e306 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,8 @@ name: 3. Deploy to Azure on: - push: - branches: - - github-actions-test + release: + types: [published] # enables manual triggers workflow_dispatch: @@ -19,17 +18,38 @@ jobs: runs-on: ubuntu-latest needs: [] steps: - - name: Checkout Repository - uses: actions/checkout@v4 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Log in to Azure - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} + - name: Get release version + id: get_version + run: | + if [ "${{ github.event_name }}" = "release" ]; then + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + else + echo "version=${{ inputs.release_id }}" >> $GITHUB_OUTPUT + fi - - name: Deploy to Azure Container Apps - run: | - az containerapp update \ - --name electify \ - --resource-group electify-app \ - --image cliedl/electify:1.0.1 + - name: Build Docker Image + run: | + docker build --platform linux/amd64 -t cliedl/electify:${{ steps.get_version.outputs.version }} . + + - name: Push Docker Image + run: | + docker push cliedl/electify:${{ steps.get_version.outputs.version }} + + - name: Log in to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Build and deploy Container App + uses: azure/container-apps-deploy-action@v1 + with: + acrName: myregistry + containerAppName: my-container-app + resourceGroup: my-rg + imageToDeploy: cliedl/electify:${{ steps.get_version.outputs.version }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3de4f3..5385bb2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,8 @@ name: 2. Draft Release on: push: branches: - - github-actions-test - main + - github-actions-test pull_request: types: - closed From fe0684561a2bfd39d9a777707e11bece72cdd5c4 Mon Sep 17 00:00:00 2001 From: cliedl Date: Wed, 5 Feb 2025 21:42:44 +0100 Subject: [PATCH 10/10] deleted test-branch from actions --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5385bb2..294437e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - github-actions-test pull_request: types: - closed