-
Notifications
You must be signed in to change notification settings - Fork 1
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 #101 from alma/devx/dex-892-update-cicd-on-sfcc-ca…
…rtridge [DEX-892] Add Taskfile, update pre-commits and release workflow
- Loading branch information
Showing
21 changed files
with
15,104 additions
and
111 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
cartridges/int_alma/cartridge/static/ | ||
coverage |
Validating CODEOWNERS rules …
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,8 @@ | ||
# Grant ownership of all files by default to the ECOM integrations squad | ||
* @alma/squad-e-commerce-integrations | ||
|
||
# Grant DevX ownership of Github workflows and actions | ||
.github @alma/squad-devx | ||
|
||
# Grant DevX ownership of Taskfile | ||
Taskfile.yml @alma/squad-devx |
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,21 @@ | ||
name-template: 'v$RESOLVED_VERSION' | ||
tag-template: 'v$RESOLVED_VERSION' | ||
|
||
template: | | ||
$CHANGES | ||
change-template: '- $TITLE' | ||
change-title-escapes: '\<*_&#@`' | ||
version-resolver: | ||
major: | ||
labels: | ||
- 'major' | ||
minor: | ||
labels: | ||
- 'minor' | ||
- 'type: feature' | ||
patch: | ||
labels: | ||
- 'patch' | ||
default: patch |
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,36 @@ | ||
# This workflow is triggered when a pull request is merged and the label 'release' is present. | ||
# It opens a pull request to backport the changes from main to develop. | ||
name: Create backport pull request | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
jobs: | ||
|
||
create-backport-pull-request: | ||
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release')) }} | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
|
||
# See https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another | ||
- name: Fetch main branch | ||
run: | | ||
git fetch origin main:main | ||
git reset --hard main | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: 'chore: backport main to develop' | ||
title: Backport main to develop | ||
branch: chore/backport-main-to-develop | ||
base: develop |
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,66 @@ | ||
name: Create hotfix pull request | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
changelog-message: | ||
type: string | ||
description: The message to add to the changelog | ||
required: true | ||
|
||
jobs: | ||
|
||
create-hotfix-pull-request: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Release drafter | ||
uses: release-drafter/release-drafter@v6 | ||
id: release-drafter | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update release draft | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { owner, repo } = context.repo; | ||
await github.rest.repos.updateRelease({ | ||
owner, | ||
repo, | ||
release_id: "${{ steps.release-drafter.outputs.id }}", | ||
draft: true, | ||
body: "### 🐛 Bug Fixes\n ${{ inputs.changelog-message }}\n" | ||
}); | ||
- name: Update CHANGELOG.md file | ||
uses: stefanzweifel/changelog-updater-action@v1 | ||
with: | ||
latest-version: ${{ steps.release-drafter.outputs.tag_name }} | ||
release-notes: "### 🐛 Bug Fixes\n ${{ inputs.changelog-message }}\n" | ||
|
||
- name: Update other files | ||
run: | | ||
./scripts/update-files-with-release-version.sh ${{ steps.release-drafter.outputs.tag_name }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: 'chore: update version' | ||
title: Release ${{ steps.release-drafter.outputs.tag_name }} | ||
body: | | ||
Update version to ${{ steps.release-drafter.outputs.tag_name }} | ||
### Checklist of actions to be done before merging | ||
- [ ] Review and update the CHANGELOG.md if needed | ||
- [ ] Review and update the Github release draft if needed | ||
- [ ] Review the files updated with the new version number in the commit named "chore: update version" | ||
branch: hotfix/${{ steps.release-drafter.outputs.tag_name }} | ||
base: main | ||
labels: hotfix, release | ||
|
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,108 @@ | ||
# This workflow is triggered when a pull request is merged and the label 'release' is present. | ||
# It fetches the last draft release, updates it to a non-draft release and sends a Slack message with the release notes. | ||
name: Publish Release | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
|
||
release: | ||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Install taskfile.dev | ||
uses: arduino/setup-task@v2 | ||
with: | ||
version: 3.x | ||
repo-token: ${{ github.token }} | ||
|
||
- name: Fetch last draft release | ||
id: fetch-release-draft | ||
shell: bash | ||
run: | | ||
# Call Github releases API and filter draft releases | ||
DRAFT_RELEASE=$(curl \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ github.token }}" \ | ||
https://api.github.com/repos/${{ github.repository }}/releases | \ | ||
jq 'map(select(.draft == true))' \ | ||
) | ||
# Fail if 0 or more than 1 draft release is found | ||
if [[ $(echo $DRAFT_RELEASE | jq 'length') -ne 1 ]] | ||
then | ||
echo "No draft release found or more than one draft release found" | ||
exit 1 | ||
fi | ||
DRAFT_RELEASE=$(echo $DRAFT_RELEASE | jq first) | ||
# Retrieve name, id and body of the draft release | ||
# We need to remove the quotes from the JSON output | ||
NAME=$(echo $DRAFT_RELEASE | jq '.name' | sed 's/"//g') | ||
ID=$(echo $DRAFT_RELEASE | jq '.id') | ||
BODY=$(echo $DRAFT_RELEASE | jq '.body' | sed 's/"//g') | ||
# Add URLs to GitHub pull requests | ||
PULL_REQUEST_URL_START=${{ github.server_url }}/${{ github.repository }}/pull/ | ||
ESCAPED_PULL_REQUEST_URL_START=$(printf '%s\n' "$PULL_REQUEST_URL_START" | sed -e 's/[\/&]/\\&/g') | ||
BODY=$(echo -e "$BODY" | sed -E "s/#([0-9]+)/[#\1](${ESCAPED_PULL_REQUEST_URL_START}\1)/g") | ||
# Add URLs to GitHub profiles | ||
PROFILE_URL_START=${{ github.server_url }}/ | ||
ESCAPED_PROFILE_URL_START=$(printf '%s\n' "$PROFILE_URL_START" | sed -e 's/[\/&]/\\&/g') | ||
BODY=$(echo -e "$BODY" | sed -E "s/@([[:alnum:]-]+)/[@\1](${ESCAPED_PROFILE_URL_START}\1)/g") | ||
# Write the output variables | ||
echo "name=$NAME" >> $GITHUB_OUTPUT | ||
echo "id=$ID" >> $GITHUB_OUTPUT | ||
echo "body<<EOF" >> $GITHUB_OUTPUT | ||
echo -e "$BODY" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Publish Github release | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { owner, repo } = context.repo; | ||
await github.rest.repos.updateRelease({ | ||
owner, | ||
repo, | ||
release_id: "${{ steps.fetch-release-draft.outputs.id }}", | ||
draft: false, | ||
make_latest: true, | ||
tag_name: "${{ steps.fetch-release-draft.outputs.name }}" | ||
}); | ||
- name: Format release notes for Slack | ||
# v1.0.2 cannot be used as it is not correctly handling the newlines | ||
uses: LoveToKnow/[email protected] | ||
id: slack-markdown-release-notes | ||
with: | ||
text: | | ||
New release of ${{ github.repository }}, **[${{ steps.fetch-release-draft.outputs.name }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.fetch-release-draft.outputs.name }})**: | ||
${{ steps.fetch-release-draft.outputs.body }} | ||
- name: Send changelog to Slack | ||
uses: slackapi/[email protected] | ||
with: | ||
# TODO: Replace with channel #alma_changelog (id: CR9C57YM6) once full testing is done | ||
# Channel `#devx-experiments` | ||
channel-id: C04MQ9VEWRF | ||
slack-message: ${{ steps.slack-markdown-release-notes.outputs.text }} | ||
payload: | | ||
{ | ||
"username": "${{ github.event.sender.login }}", | ||
"icon_url": "${{ github.event.sender.avatar_url }}" | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_RELEASE_CHANGELOG_BOT_TOKEN }} |
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,56 @@ | ||
name: Create release pull request | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
create-release-pull-request: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
persist-credentials: false | ||
|
||
# This is needed to get all changes from develop in the PR | ||
# It won't work if we checkout from develop, see https://github.com/peter-evans/create-pull-request/issues/2841 | ||
# See https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another | ||
- name: Fetch develop branch | ||
run: | | ||
git fetch origin develop:develop | ||
git reset --hard develop | ||
- name: Create release draft | ||
uses: release-drafter/release-drafter@v6 | ||
id: release-drafter | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update CHANGELOG.md | ||
uses: stefanzweifel/changelog-updater-action@v1 | ||
with: | ||
latest-version: ${{ steps.release-drafter.outputs.tag_name }} | ||
release-notes: ${{ steps.release-drafter.outputs.body }} | ||
|
||
- name: Update files with release version | ||
run: | | ||
./scripts/update-files-with-release-version.sh ${{ steps.release-drafter.outputs.tag_name }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: 'chore: update version' | ||
title: Release ${{ steps.release-drafter.outputs.tag_name }} | ||
body: | | ||
Update version to ${{ steps.release-drafter.outputs.tag_name }} | ||
### Checklist of actions to be done before merging | ||
- [ ] Review and update the CHANGELOG.md if needed | ||
- [ ] Review and update the Github release draft if needed | ||
- [ ] Review the files updated with the new version number in the commit named "chore: update version" | ||
branch: release/${{ steps.release-drafter.outputs.tag_name }} | ||
base: main | ||
labels: release |
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 @@ | ||
v12.22.12 |
Oops, something went wrong.