Skip to content

Commit

Permalink
[Experimental] Add auto tag GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Jan 25, 2020
1 parent 0e2f66a commit 43d3391
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Auto Tag

on:
schedule:
- cron: '0 0 31 1 *'

env:
NEXT_TAG: '41'
SSH_REPO: 'git@github.com:${{ github.repository }}.git'

jobs:
tag:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Checkout
uses: actions/checkout@v2.0.0
with:
repository: 'rust-lang/rust'
ref: '1.${{ env.NEXT_TAG }}.0'
path: 'rust'
- name: Get Clippy commit
working-directory: rust
run: |
git submodule init src/tools/clippy
CLIPPY_SHA=$(git submodule status -- src/tools/clippy | grep -o '\s[0-9a-f]*\s' | tr -d '[:space:]')
echo "::set-env name=CLIPPY_SHA::$CLIPPY_SHA"
- name: Set SSH deploy key
run: |
eval "$(ssh-agens -s)"
ssh-add - <<< ${{ secrets.DEPLOY_KEY }}
- name: Tag Clippy commit
run: |
git checkout $CLIPPY_SHA
git tag 'rust-1.$NEXT_TAG.0'
git push $SSH_REPO --tags
- name: Update GHA Auto Tag
run: |
git checkout master
TIME=$(date -u +%s)
let NEXT_RELEASE="$TIME+6*7*24*60*60"
DATE=$(date -u --date="@$NEXT_RELEASE" +%-d\ %-m)
CRON="0 0 $DATE *"
sed -i "s/cron: '[0-9* ]*'/cron: '$CRON'/" .github/workflows/tag.yml
let NEW_TAG="$NEXT_TAG+1"
sed -i "s/NEXT_TAG: '[0-9]*'/NEXT_TAG: '$NEW_TAG'/" .github/workflows/tag.yml
git add .github/workflows/tag.yml
git commit -m "Update GHA tag workflow"
git push $SSH_REPO

0 comments on commit 43d3391

Please sign in to comment.