From 609002bccd4ca832db5fa0e69232d825a69e83f8 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 18:59:29 +0100 Subject: [PATCH 1/8] chore: Add workflow to deploy application --- .github/workflows/deploy.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..9052331 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: Deploy +on: + workflow_dispatch: + inputs: + image_version: + description: Tag of the application to deploy + default: latest + required: false + target: + description: Target overlay of deployment + default: test + required: true +permissions: + contents: write +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: 2martens/cloud-configuration + - name: Update image version + run: | + mkdir $HOME/bin + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 -O $HOME/bin/yq && chmod +x $HOME/bin/yq + sed -i -r "s/(tag:).*/\1\ \"${{ inputs.image_version |}\"/" argocd/timetable/${{ inputs.target }}/overwrite_values.yaml + cd argocd/timetable/${{ inputs.target }} && $HOME/bin/yq '. *= load("overwrite_values.yaml")' default_values.yaml > values.yaml + - name: Save modified variable file + run: | + git add argocd/timetable/${{ inputs.target }}/* + git config --global user.name 'Your Name' + git config --global user.email 'your-username@users.noreply.github.com' + git diff-index --quiet HEAD || git commit -m "chore: Change timetable_image_version to ${{ inputs.image_version }}" + git push \ No newline at end of file From 5e77ea3a0c1287235153ba2c694aabd03a9720d7 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:08:07 +0100 Subject: [PATCH 2/8] chore: Fix typo --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 9052331..32bd0af 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -24,7 +24,7 @@ jobs: run: | mkdir $HOME/bin wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 -O $HOME/bin/yq && chmod +x $HOME/bin/yq - sed -i -r "s/(tag:).*/\1\ \"${{ inputs.image_version |}\"/" argocd/timetable/${{ inputs.target }}/overwrite_values.yaml + sed -i -r "s/(tag:).*/\1\ \"${{ inputs.image_version }}\"/" argocd/timetable/${{ inputs.target }}/overwrite_values.yaml cd argocd/timetable/${{ inputs.target }} && $HOME/bin/yq '. *= load("overwrite_values.yaml")' default_values.yaml > values.yaml - name: Save modified variable file run: | From 25c5b92aaff5cbf5f7684b08f0f26181889e54fd Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:09:31 +0100 Subject: [PATCH 3/8] chore: Use amd version --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 32bd0af..c00e515 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -23,7 +23,7 @@ jobs: - name: Update image version run: | mkdir $HOME/bin - wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 -O $HOME/bin/yq && chmod +x $HOME/bin/yq + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O $HOME/bin/yq && chmod +x $HOME/bin/yq sed -i -r "s/(tag:).*/\1\ \"${{ inputs.image_version }}\"/" argocd/timetable/${{ inputs.target }}/overwrite_values.yaml cd argocd/timetable/${{ inputs.target }} && $HOME/bin/yq '. *= load("overwrite_values.yaml")' default_values.yaml > values.yaml - name: Save modified variable file From ddff93e70f888f8029a66dccb0a7e8e7c45b3ee6 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:16:45 +0100 Subject: [PATCH 4/8] chore: Call workflow in changed repository --- .github/workflows/deploy.yaml | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index c00e515..7d11578 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -10,26 +10,11 @@ on: description: Target overlay of deployment default: test required: true -permissions: - contents: write jobs: deploy: name: Deploy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - repository: 2martens/cloud-configuration - - name: Update image version - run: | - mkdir $HOME/bin - wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O $HOME/bin/yq && chmod +x $HOME/bin/yq - sed -i -r "s/(tag:).*/\1\ \"${{ inputs.image_version }}\"/" argocd/timetable/${{ inputs.target }}/overwrite_values.yaml - cd argocd/timetable/${{ inputs.target }} && $HOME/bin/yq '. *= load("overwrite_values.yaml")' default_values.yaml > values.yaml - - name: Save modified variable file - run: | - git add argocd/timetable/${{ inputs.target }}/* - git config --global user.name 'Your Name' - git config --global user.email 'your-username@users.noreply.github.com' - git diff-index --quiet HEAD || git commit -m "chore: Change timetable_image_version to ${{ inputs.image_version }}" - git push \ No newline at end of file + uses: 2martens/cloud-configuration/.github/workflows/deploy.yaml + with: + application: timetable + image_version: inputs.image_version + target: inputs.target From 8b178ad039337037e3e9de93f7007edcdd895772 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:17:49 +0100 Subject: [PATCH 5/8] chore: Use workflow in main branch --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 7d11578..9d85981 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -13,7 +13,7 @@ on: jobs: deploy: name: Deploy - uses: 2martens/cloud-configuration/.github/workflows/deploy.yaml + uses: 2martens/cloud-configuration/.github/workflows/deploy.yaml@main with: application: timetable image_version: inputs.image_version From b1408e760c1a32f0edb239333a1b988e4dd13967 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:18:36 +0100 Subject: [PATCH 6/8] chore: Allow contents write --- .github/workflows/deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 9d85981..36fac4e 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -10,6 +10,8 @@ on: description: Target overlay of deployment default: test required: true +permissions: + contents: write jobs: deploy: name: Deploy From b43f004de8c09a4383d957b149f58bc137499809 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:22:42 +0100 Subject: [PATCH 7/8] chore: Pass along actual values of inputs --- .github/workflows/deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 36fac4e..ede0a23 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -18,5 +18,5 @@ jobs: uses: 2martens/cloud-configuration/.github/workflows/deploy.yaml@main with: application: timetable - image_version: inputs.image_version - target: inputs.target + image_version: ${{ inputs.image_version }} + target: ${{ inputs.target }} From 5a0edfad45b48641a46116cb6e0ae63e10bb0131 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jan 2024 19:36:44 +0100 Subject: [PATCH 8/8] chore: Pass along secret --- .github/workflows/deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index ede0a23..d977fef 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -20,3 +20,5 @@ jobs: application: timetable image_version: ${{ inputs.image_version }} target: ${{ inputs.target }} + secrets: + ACTIONS_GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}