Skip to content

Build and Push Tag to https://github.com/ECTLab/AIaaS-gRPC-protos-Autogenerated-Python #84

Build and Push Tag to https://github.com/ECTLab/AIaaS-gRPC-protos-Autogenerated-Python

Build and Push Tag to https://github.com/ECTLab/AIaaS-gRPC-protos-Autogenerated-Python #84

name: Build and Push Tag to https://github.com/ECTLab/AIaaS-gRPC-protos-Autogenerated-Python
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]*.[0-9]*.[0-9]*'
repository_dispatch:
types: [tag-created]
env:
DESTINATION_REPO: ECTLab/AIaaS-gRPC-protos-Autogenerated-Python
DESTINATION_BRANCH: master
DESTINATION_TOKEN: ${{ secrets.PYTHON_DESTINATION_TOKEN }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Install dependencies
run: |
make install_python_requirements
- name: Build
run: |
make generate_python_protos
- name: Checkout destination repo
uses: actions/checkout@v2
with:
repository: ${{ env.DESTINATION_REPO }}
ref: ${{ env.DESTINATION_BRANCH }}
token: ${{ env.DESTINATION_TOKEN }}
path: destination-repo
- name: Copy files
run: |
rm -rf destination-repo/AIaaS_interface/
mkdir -p destination-repo/AIaaS_interface/
cp -r AIaaS_interface/* destination-repo/AIaaS_interface/
- name: Commit changes
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
echo "Tag name: $TAG_NAME"
echo "payload: ${{ github.event.client_payload.tag_name }}"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
fi
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')
cd destination-repo
LAST_GIT_COMMIT_NAME=$(git log -1 --pretty=format:'%an')
LAST_GIT_COMMIT_EMAIL=$(git log -1 --pretty=format:'%ae')
git config user.name "$LAST_GIT_COMMIT_NAME"
git config user.email "$LAST_GIT_COMMIT_EMAIL"
git add .
echo "git tag to be pushed: '$TAG_NAME'"
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit. push only new tag."
git tag $TAG_NAME
git push --follow-tags
else
git commit -m "$TAG_NAME | $LAST_COMMIT_MESSAGE"
git tag "$TAG_NAME"
git push --follow-tags
git push origin master
fi
env:
TAG_NAME: ${{ github.event.client_payload.tag_name }}