Skip to content

Commit

Permalink
Merge pull request #68 from earthly/ido-auto-update-major-branch
Browse files Browse the repository at this point in the history
Auto update major branch upon a new release
  • Loading branch information
idodod authored Mar 26, 2024
2 parents fcc9066 + 9b9f454 commit 36a0143
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/renovate-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:

jobs:
update-renovate-branch:
if: github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.head_ref, 'renovate/') && github.head_ref == 'renovate[bot]'
if: github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.head_ref, 'renovate/') && github.actor == 'renovate[bot]'
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/update-major-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Update Major Version Branch

on:
release:
types: [released]

jobs:
update-major-version-branch:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
EARTHLY_CONVERSION_PARALLELISM: "5"
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
EARTHLY_INSTALL_ID: "earthly-actions-setup-githubactions"
steps:
- uses: earthly/actions/setup-earthly@v1
with:
version: v0.8.6
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Update Branch
run: earthly --ci -P +merge-release-to-major-branch --RELEASE_TAG=${{ github.ref }}
28 changes: 25 additions & 3 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ VERSION 0.8

PROJECT earthly-technologies/core

ARG EARTHLY_LIB_VERSION=3.0.1
IMPORT github.com/earthly/lib/utils/git:$EARTHLY_LIB_VERSION AS git

npm-base:
FROM node:21.7-alpine3.19
COPY ./package.json ./
Expand Down Expand Up @@ -103,10 +106,8 @@ update-dist-for-renovate:

ARG git_repo="earthly/actions-setup"
ARG git_url="[email protected]:$git_repo"
ARG earthly_lib_version=3.0.1
ARG SECRET_PATH=littleredcorvette-id_rsa
DO --pass-args github.com/earthly/lib/utils/git:$earthly_lib_version+DEEP_CLONE \
--GIT_URL=$git_url --SECRET_PATH=$SECRET_PATH
DO --pass-args git+DEEP_CLONE --GIT_URL=$git_url --SECRET_PATH=$SECRET_PATH

ARG EARTHLY_GIT_BRANCH
LET branch=$EARTHLY_GIT_BRANCH
Expand All @@ -117,6 +118,27 @@ update-dist-for-renovate:
RUN --push --mount=type=secret,id=$SECRET_PATH,mode=0400,target=/root/.ssh/id_rsa \
git push origin $branch

merge-release-to-major-branch:
FROM alpine/git
RUN git config --global user.name "littleredcorvette" && \
git config --global user.email "[email protected]" && \
git config --global url."[email protected]:".insteadOf "https://github.com/"

ARG git_repo="earthly/actions-setup"
ARG git_url="[email protected]:$git_repo"
ARG SECRET_PATH=littleredcorvette-id_rsa
DO --pass-args git+DEEP_CLONE --GIT_URL=$git_url --SECRET_PATH=$SECRET_PATH

ARG --required RELEASE_TAG
LET tag=${RELEASE_TAG#refs/tags/}
LET major=$tag
SET major=$(echo ${major%.*})
SET major=$(echo ${major%.*})
RUN --mount=type=secret,id=$SECRET_PATH,mode=0400,target=/root/.ssh/id_rsa \
git checkout $major && git merge --ff-only $tag
RUN --push --mount=type=secret,id=$SECRET_PATH,mode=0400,target=/root/.ssh/id_rsa \
git push origin $major

all:
BUILD +lint
BUILD +lint-newline
Expand Down

0 comments on commit 36a0143

Please sign in to comment.