-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding ci/cd to shopify tracker repository (#43)
* fix: initial commit * fix: edit in docker image build * fix: partial address of review comments * fix: review comments addressed * chore(release): 1.2.0 * fix: review comments addressed * feat: adding rollback action * fix: cloning the devops repo * fix: review comments address part 1 * fix: adding new action for docker build
- Loading branch information
1 parent
dd8bc39
commit 666f7e3
Showing
18 changed files
with
11,679 additions
and
123 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,13 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
es2021: true, | ||
commonjs: true, | ||
}, | ||
extends: ["prettier", "eslint:recommended", "plugin:json/recommended"], | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
schedule: | ||
interval: 'weekly' |
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,73 @@ | ||
name: Docker Image CI for shopify-tracker | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
types: | ||
- closed | ||
branches: | ||
- main | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
build: | ||
name: Test and build image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Get image version | ||
id: get-version | ||
run: | | ||
VERSION=$(jq -r .version package.json) | ||
echo "Version: $VERSION" | ||
echo "::set-output name=version::$VERSION" | ||
- name: Build Shopify Tracker Docker Image | ||
# Only merged pull requests must trigger | ||
if: github.event.pull_request.merged == true | ||
uses: ./.github/workflows/build-push-docker-image.yml | ||
with: | ||
img_tag: rudder-shopify-tracker:${{steps.get-version.outputs.version}} | ||
|
||
- name: Extract branch name | ||
id: extract_branch_name | ||
run: | | ||
branch_name=$(git rev-parse --abbrev-ref HEAD) | ||
echo "branch_name=$branch_name" | ||
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT | ||
- name: Initialize Mandatory Git Config | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "noreply@github.com" | ||
- name: Clone Devops Repo | ||
run: | | ||
git clone https://${{secrets.PAT}}@github.com/rudderlabs/rudder-devops.git | ||
- name: Update Helm Chart and Raise Pull Request For Shopify Tracker | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT }} | ||
SP_IMAGE_REPOSITORY: rudderstack/rudder-shopify-tracker | ||
VERSION: ${{steps.get-version.outputs.version}} | ||
run: | | ||
cd rudder-devops | ||
git checkout -b shopify-tracker-$VERSION ${{steps.extract_branch_name.outputs.branch_name}} | ||
cd helm-charts/helm/shopify-tracking | ||
yq eval -i ".image.tag=\"$VERSION\"" values.yaml | ||
yq eval -i ".image.repository=\"$SP_IMAGE_REPOSITORY\"" values.yaml | ||
git add values.yaml | ||
git commit -m "chore: upgrade shopify tracker to $VERSION" | ||
git push -u origin shopify-tracker-$VERSION | ||
hub pull-request -m "chore: upgrade shopify tracker to $VERSION" |
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,33 @@ | ||
name: Build Shopify Tracker Docker Image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
img_tag: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build-transformer-image-arm64: | ||
name: Build Shopify Tracker Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3.5.3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2.1.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and Push Images | ||
if: ((startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true) | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: rudderstack/rudder-shopify-tracker:${{ inputs.img_tag }} |
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,17 @@ | ||
name: Check PR Title | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
|
||
jobs: | ||
check-pr-title: | ||
name: Check PR Title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check PR Title | ||
uses: rudderlabs/github-action-check-pr-title@v1.0.7 |
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,23 @@ | ||
name: Create New Hotfix Branch | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
hotfix_name: | ||
description: Hotfix branch name | ||
required: true | ||
|
||
jobs: | ||
create-branch: | ||
name: Create New Hotfix Branch | ||
runs-on: ubuntu-latest | ||
|
||
# Only allow these users to create new hotfix branch from 'main' | ||
if: github.ref == 'refs/heads/main' && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'utsabc' || github.actor == 'shrouti1507') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'shrouti1507' || github.triggering_actor == 'utsabc') | ||
steps: | ||
- name: Create Branch | ||
uses: peterjgrainger/action-create-branch@v2.4.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT }} | ||
with: | ||
branch: 'hotfix/${{ inputs.hotfix_name }}' |
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Draft New Release | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
draft-new-release: | ||
name: Draft New Release | ||
runs-on: ubuntu-latest | ||
|
||
# Only allow release stakeholders to initiate releases | ||
if: (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')) && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'utsabc' || github.actor == 'shrouti1507') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'utsabc' || github.triggering_actor == 'shrouti1507') | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3.5.0 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3.6.0 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
- name: Install Dependencies | ||
env: | ||
HUSKY: 0 | ||
run: | | ||
npm ci | ||
# In order to make a commit, we need to initialize a user. | ||
# You may choose to write something less generic here if you want, it doesn't matter functionality wise. | ||
- name: Initialize Mandatory Git Config | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "noreply@github.com" | ||
# Calculate the next release version based on conventional semantic release | ||
- name: Create Release Branch | ||
id: create-release | ||
env: | ||
HUSKY: 0 | ||
run: | | ||
source_branch_name=${GITHUB_REF##*/} | ||
release_type=release | ||
grep -q "hotfix/" <<< "${GITHUB_REF}" && release_type=hotfix-release | ||
git fetch origin main | ||
git fetch --tags origin | ||
git merge origin/main | ||
current_version=$(jq -r .version package.json) | ||
npm run release -- --skip.commit --skip.tag --skip.changelog | ||
new_version=$(jq -r .version package.json) | ||
git reset --hard | ||
branch_name="${release_type}/v${new_version}" | ||
echo "Source branch for new release is $source_branch_name" | ||
echo "Current version is $current_version" | ||
echo "Release type is $release_type" | ||
echo "New version is $new_version" | ||
echo "New release branch name is $branch_name" | ||
git checkout -b "$branch_name" | ||
git push --set-upstream origin "$branch_name" | ||
echo "source_branch_name=$source_branch_name" >> $GITHUB_OUTPUT | ||
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT | ||
echo "new_version=$new_version" >> $GITHUB_OUTPUT | ||
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV | ||
echo "NEW_VERSION_VALUE=$new_version" >> $GITHUB_ENV | ||
- name: Update Changelog & Bump Version | ||
id: finish-release | ||
env: | ||
HUSKY: 0 | ||
run: | | ||
echo "Current version: $CURRENT_VERSION_VALUE" | ||
echo "New version: $NEW_VERSION_VALUE" | ||
npm run release -- -a --skip.tag --no-verify | ||
git push | ||
- name: Create Pull Request | ||
uses: repo-sync/pull-request@v2.12.1 | ||
with: | ||
source_branch: ${{ steps.create-release.outputs.branch_name }} | ||
destination_branch: 'main' | ||
github_token: ${{ secrets.PAT }} | ||
pr_title: 'chore(release): pull ${{ steps.create-release.outputs.branch_name }} into main' | ||
pr_body: ':crown: *An automated PR*' |
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 @@ | ||
name: Handle Stale PRs, Issues and Branches | ||
|
||
on: | ||
schedule: | ||
# Run everyday at 1 AM | ||
- cron: '0 1 * * *' | ||
|
||
jobs: | ||
prs: | ||
name: Clean Up Stale PRs and Issues | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/stale@v8.0.0 | ||
with: | ||
repo-token: ${{ secrets.PAT }} | ||
operations-per-run: 200 | ||
stale-pr-message: 'This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR.' | ||
stale-issue-message: 'This issue is considered to be stale. It has been open for 30 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the issue.' | ||
days-before-pr-stale: 20 | ||
days-before-pr-close: 7 | ||
days-before-issue-stale: 30 | ||
days-before-issue-close: 7 | ||
stale-pr-label: 'Stale' | ||
stale-issue-label: 'Stale' | ||
|
||
branches: | ||
name: Cleanup Stale Branches | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3.5.3 | ||
|
||
- name: Delete Old Branches | ||
uses: beatlabs/delete-old-branches-action@v0.0.9 | ||
with: | ||
repo_token: ${{ secrets.PAT }} | ||
date: '3 months ago' | ||
dry_run: false | ||
delete_tags: false | ||
extra_protected_branch_regex: ^(main|release/.*|develop|hotfix/.*|hotfix-release/.*)$ | ||
exclude_open_pr_branches: true |
Oops, something went wrong.