Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Aug 12, 2024
1 parent de9972d commit 3eb75b2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build-int-on-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
paths-ignore:
- 'doc/**'
- '**.md'

jobs:
build-image:
uses: ./.github/workflows/reusable_lint_test_build_update.yaml
with:
image_repo: "harbor.puzzle.ch/decidim/stlu/int/rails"
configmanagement: "gitlab.puzzle.ch/pitc_ruby/decidim-configmanagement"
image_repo: "https://harbor.puzzle.ch"
image_url: "harbor.puzzle.ch/decidim/stlu-int-rails"
configmanagement: "gitlab.puzzle.ch/pitc_ruby/decidim-configmanagement/"
configmanagement_branch: "feature/cloudscale"
kustomization_path: "./deployments/pitc-stlu-decidim-int/kustomization.yaml"


secrets: inherit
8 changes: 5 additions & 3 deletions .github/workflows/reusable_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
images:
description: 'Images arguments for docker/metadata-action'
type: string
required: false
required: true
flavor:
description: 'Flavor argument for docker/metadata-action'
type: string
Expand All @@ -41,9 +41,11 @@ on:
description: List of set tags
value: ${{ jobs.build.outputs.tags }}
labels:
description:
description: Label output
value: ${{ jobs.build.outputs.labels }}
json: ${{ jobs.build.outputs.json }}
json:
description: JSON output
value: ${{ jobs.build.outputs.json }}

jobs:
build:
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/reusable_lint_test_build_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ on:
workflow_call:
inputs:
image_repo:
description: "Image repo to push image to"
description: "Image repo"
type: string
required: true
image_url:
description: "URL to push image to"
type: string
required: true
configmanagement:
description: "Configmanagement to write image tag to"
type: string
required: true
configmanagement_branch:
description: "Configmanagement branch to put the image tag into"
type: string
required: false
kustomization_path:
description: "Path to kustomization file"
type: string
Expand All @@ -24,14 +32,19 @@ jobs:
build:
needs: [lint, test]
uses: ./.github/workflows/reusable_build.yaml
secrets: inherit
secrets:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
with:
repository_url: ${{ inputs.image_repo }}
images: ${{ inputs.image_url }}
flavor: latest=true
update_tag:
needs: [build]
uses: ./.github/workflows/reusable_update_image.yaml
secrets: inherit
with:
repository: ${{ inputs.configmanagement }}
repository_branch: ${{ inputs.configmanagement_branch }}
file: ${{ inputs.kustomization_path }}
json: ${{ jobs.build.outputs.json }}
json: ${{ needs.build.outputs.json }}
2 changes: 1 addition & 1 deletion .github/workflows/reusable_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
postgres:
image: 'postgis/postgis:14-3.3-alpine'
env:
POSTGRESQL_PASSWORD: 'postgres'
POSTGRES_PASSWORD: 'postgres'
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/reusable_update_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ on:
required: true
repository_username:
description: 'Username for repository login'
type: string
required: false
default: 'git'
repository_branch:
description: "The branch that should be edited"
type: string
required: false
default: main
file:
description: 'File in the repo to update'
type: string
Expand Down Expand Up @@ -46,9 +52,11 @@ jobs:
REPO_URL: ${{ inputs.repository }}
REPO_USER: ${{ inputs.repository_username }}
REPO_TOKEN: ${{ secrets.REPOSITORY_TOKEN }}
REPO_BRANCH: ${{ inputs.repository_branch }}
run: |
git clone https://${REPO_USER}:${REPO_TOKEN}@${REPO_URL} ./management_repo
cd ./management_repo
git switch ${REPO_BRANCH}
git config user.name "Decidim Github Action Image updater"
git config user.email "[email protected]"
git remote set-url origin "https://${REPO_USER}:${REPO_TOKEN}@${REPO_URL}"
Expand All @@ -60,9 +68,10 @@ jobs:
JSON: ${{ inputs.json }}
with:
cmd: |
TAG=$(echo "${JSON}" | yq -r '.tags[] | select(. | test("sha-"))')
echo $TAG
yq -i '.images.[] | select(.name == env(IMAGE_REF)) += {"newTag": env(TAG)}' "${FILE}"
ls -lha
# TAG=$(echo "${JSON}" | yq -r '.tags[] | select(. | test("sha-"))')
# echo $TAG
# yq -i '.images.[] | select(.name == env(IMAGE_REF)) += {"newTag": env(TAG)}' "${FILE}"
- name: Commit & push back to repository
env:
IMAGE_REF: ${{ inputs.image_ref }}
Expand Down

0 comments on commit 3eb75b2

Please sign in to comment.