Skip to content

Commit

Permalink
Automate pulling latest master branch & tags, and creating new releas…
Browse files Browse the repository at this point in the history
…e branches (#7)

* Automate pulling latest master branch & tags, and creating new release branches
  • Loading branch information
luigi-sayson authored and bwschmidt committed Apr 5, 2022
1 parent 9c72ed9 commit ae0d070
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/auto-pull-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Pull in latest master branch and tags from official Prebid.js repo, trigger auto-release-branch if there are new tags
name: auto-pull-upstream
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * *'

jobs:
pull:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: '${{ secrets.JENKINS_GITHUB_TOKEN }}'
fetch-depth: 0
- name: Pull
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout master
git remote add upstream https://github.com/prebid/Prebid.js.git
git pull upstream master
git fetch upstream --tags
NEW_VERSIONS=$(git show-ref --tags | grep -v -F "$(git ls-remote --tags origin | grep -v '\^{}' | cut -f 2)" | cut -d "/" -f 3)
git push origin master --tags
for version in $NEW_VERSIONS
# Trigger auto-release-branch workflow
do
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-u jenkins-openx:${{ secrets.JENKINS_GITHUB_TOKEN }} \
https://api.github.com/repos/openx/prebid-js-internal/actions/workflows/auto-release-branch.yml/dispatches \
-d '{"ref":"openx/master", "inputs": {"tag": "'"$version"'" }}'
done
41 changes: 41 additions & 0 deletions .github/workflows/auto-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Create a release branch when there is a new official tag
name: auto-release-branch
on:
workflow_dispatch:
inputs:
tag:
description: 'Official tag to be used in making a release branch/tag'

jobs:
make-release-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
- name: Create release branch
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
VERSION=${{ github.event.inputs.tag }}
echo $VERSION
git fetch -unf origin $VERSION:refs/tags/$VERSION
git checkout $VERSION
git checkout -b openx/$VERSION
git fetch -unf origin openx/master
# These files are not in the public prebid.js repo, so they aren't included by the 'openx*' below
git checkout openx/master modules/openxRtbBidAdapter.js
git checkout openx/master test/spec/modules/openxRtbBidAdapter_spec.js
# Copy files from openx/master -> release branch.
# We copy files from the openx/master branch instead of rebasing to avoid merge conflicts.
git checkout openx/master modules/openx*
git checkout openx/master test/spec/modules/openx*
git commit --allow-empty -m "Copied files from openx/master"
git tag openx/$VERSION-1
git push origin HEAD --tags

0 comments on commit ae0d070

Please sign in to comment.