-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09b9250
commit d57f4b0
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Create charts PR | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: [ "Build and push images" ] | ||
types: | ||
- completed | ||
branches: | ||
- main | ||
|
||
jobs: | ||
create_pr: | ||
name: Create charts PR | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout datagovuk_publish repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: alphagov/datagovuk_publish | ||
path: ckanext | ||
- run: bash ./docker/create-pr.sh | ||
env: | ||
GH_TOKEN: ${{ secrets.PR_GITHUB_TOKEN }} | ||
GH_REF: ${{ github.ref_name }} | ||
IS_TAG: "false" | ||
ENVS: "integration" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
if [[ ${IS_TAG:-} = "true" ]]; then | ||
export IMAGE_TAG="${GH_REF}" | ||
export SOURCE_BRANCH="main" | ||
else | ||
export IMAGE_TAG=$(gh api repos/alphagov/datagovuk_publish/branches/${GH_REF} | jq .commit.sha -r) | ||
export SOURCE_BRANCH=${GH_REF} | ||
fi | ||
|
||
git config --global user.email "[email protected]" | ||
git config --global user.name "govuk-ci" | ||
|
||
git clone https://${GH_TOKEN}@github.com/alphagov/govuk-dgu-charts.git charts | ||
|
||
cd charts/charts/datagovuk/images | ||
|
||
for ENV in $(echo $ENVS | tr "," " "); do | ||
( | ||
BRANCH="ci/${IMAGE_TAG}-${ENV}" | ||
|
||
if git show-ref --quiet refs/heads/${BRANCH}; then | ||
echo "Branch ${BRANCH} already exists on govuk-dgu-charts" | ||
else | ||
git checkout -b ${BRANCH} | ||
|
||
cd "${ENV}" | ||
for APP in ckan pycsw solr; do | ||
yq -i '.tag = env(IMAGE_TAG)' "${APP}.yaml" | ||
yq -i '.branch = env(SOURCE_BRANCH)' "${APP}.yaml" | ||
git add "${APP}.yaml" | ||
done | ||
|
||
if [[ $(git status | grep "nothing to commit") ]]; then | ||
echo "Nothing to commit" | ||
else | ||
git commit -m "Update image tags for ${ENV} to ${IMAGE_TAG}" | ||
git push --set-upstream origin "${BRANCH}" | ||
gh pr create --title "Update image tags for ${ENV} (${IMAGE_TAG})" --base main --head "${BRANCH}" --fill | ||
fi | ||
fi | ||
) | ||
done |