-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6733 from reactioncommerce/feat/improve-docker-re…
…lease-flow feat: improve docker release flow
- Loading branch information
Showing
2 changed files
with
68 additions
and
3 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
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,60 @@ | ||
name: Docker release | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
create-docker-release-pr: | ||
if: github.event.pull_request.merged == true && github.base_ref == 'trunk' && github.head_ref == 'changeset-release/trunk' | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get new docker version | ||
id: get-docker-version | ||
run: | | ||
VERSION=$(cat ./apps/reaction/package.json | grep -m 1 version | sed 's/[^0-9.]//g') | ||
echo "NEW_DOCKER_IMAGE_VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
echo "New release docker version is $VERSION" | ||
- name: Check should build new image | ||
id: should-build-new-image | ||
run: | | ||
if curl --silent -f --head -lL https://hub.docker.com/v2/repositories/reactioncommerce/reaction/tags/${{ steps.get-docker-version.outputs.NEW_DOCKER_IMAGE_VERSION }}/ > /dev/null; then | ||
echo "RESULT=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "RESULT=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Set git user | ||
if: steps.should-build-new-image.outputs.RESULT == 'true' | ||
run: | | ||
echo ${{ steps.should-build-new-image.outputs.RESULT }} | ||
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" | ||
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" | ||
- name: Update docker-compose file | ||
if: steps.should-build-new-image.outputs.RESULT == 'true' | ||
run: | | ||
yes | cp -i docker-compose.circleci.yml docker-compose.yml | ||
sed -i "s/REACTION_VERSION/${{ steps.get-docker-version.outputs.NEW_DOCKER_IMAGE_VERSION }}/g" ./docker-compose.yml | ||
- name: Create Pull Request | ||
if: steps.should-build-new-image.outputs.RESULT == 'true' | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: Docker image release ${{ steps.get-docker-version.outputs.NEW_DOCKER_IMAGE_VERSION }} | ||
body: "Release docker image ${{ steps.get-docker-version.outputs.NEW_DOCKER_IMAGE_VERSION }}" | ||
branch: "releases/docker-image-${{ steps.get-docker-version.outputs.NEW_DOCKER_IMAGE_VERSION }}" | ||
commit-message: "feat: update docker-compose file to ${{ steps.get-docker-version.outputs.NEW_DOCKER_IMAGE_VERSION }} [Docker Release]" | ||
signoff: true |