Push tags to builds (#5793)

This commit is contained in:
Alexander Tsybulsky 2022-10-04 15:18:27 +03:00 committed by GitHub
parent 3060254d10
commit 90a55d0c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 3 deletions

View File

@ -41,6 +41,8 @@ jobs:
auto-tag:
runs-on: ubuntu-latest
outputs:
pushedTag: ${{ steps.deploy-release-tag.outputs.pushedTag }}
steps:
- uses: actions/checkout@v3
with:
@ -49,11 +51,29 @@ jobs:
with:
node-version: '16'
- name: deploy-release-tag
id: deploy-release-tag
if: github.ref == 'refs/heads/main' && github.repository == 'abapGit/abapGit'
env:
GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
GIT_USER_NAME: 'github-actions[bot]'
GIT_USER_EMAIL: 'github-actions[bot]@users.noreply.github.com'
run: ./ci/deploy-release-tag.sh
auto-tag-artifact:
runs-on: ubuntu-latest
needs: [build-merged, auto-tag]
if: github.ref == 'refs/heads/main' && github.repository == 'abapGit/abapGit' && !!needs.auto-tag.outputs.pushedTag
steps:
- uses: actions/checkout@v3
with:
repository: https://github.com/abapGit/build.git
- name: mirror tag to the artifact
env:
GITHUB_API_KEY: ${{ secrets.DEPLOY_ABAPGIT_BUILD }}
GIT_USER_NAME: 'github-actions[bot]'
GIT_USER_EMAIL: 'github-actions[bot]@users.noreply.github.com'
run: ./ci/push-tag.sh ${{ needs.auto-tag.outputs.pushedTag }}
coverage:
runs-on: ubuntu-latest
timeout-minutes: 5

View File

@ -36,9 +36,12 @@ TAG="v$VERSION_AFTER"
echo "version change detected [$VERSION_BEFORE > $VERSION_AFTER], creating a new tag ..."
# DEPLOY
git config user.email "builds@travis-ci.com"
git config user.name "Travis CI"
if [ -z $GIT_USER_EMAIL ] || [ -z $GIT_USER_NAME ]; then
echo "Failed: Git user name and email must be defined via env"
exit 1
fi
git config user.email "$GIT_USER_EMAIL"
git config user.name "$GIT_USER_NAME"
REPO_URL=$(git remote -v | grep -m1 '^origin' | sed -Ene 's#.*(https://[^[:space:]]+).*#\1#p')
PUSH_URL=$(echo "$REPO_URL" | sed -Ene "s#(https://)#\1$GITHUB_API_KEY@#p")
@ -46,3 +49,4 @@ PUSH_URL=$(echo "$REPO_URL" | sed -Ene "s#(https://)#\1$GITHUB_API_KEY@#p")
git tag $TAG || exit 1
git push $PUSH_URL $TAG || exit 1
echo "::set-output name=pushedTag::$TAG"

20
ci/push-tag.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
TAG="$1"
if [ -z $TAG ]; then
echo "Failed: Tag was not specified"
exit 1
fi
if [ -z $GIT_USER_EMAIL ] || [ -z $GIT_USER_NAME ]; then
echo "Failed: Git user name and email must be defined via env"
exit 1
fi
git config user.email "$GIT_USER_EMAIL"
git config user.name "$GIT_USER_NAME"
REPO_URL=$(git remote -v | grep -m1 '^origin' | sed -Ene 's#.*(https://[^[:space:]]+).*#\1#p')
PUSH_URL=$(echo "$REPO_URL" | sed -Ene "s#(https://)#\1$GITHUB_API_KEY@#p")
# e.g. https://$GITHUB_API_KEY@github.com/larshp/abapGit.git
git tag $TAG || exit 1
git push $PUSH_URL $TAG || exit 1