smatter-submitter is pushing a branch onward and then cleaning up #32
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Shuttle branch | |
env: | |
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_PRIVATE_KEY }} # SSH private key for pushing to smatter-submit | |
run-name: ${{ github.actor }} is pushing a branch onward and then cleaning up | |
on: | |
create: | |
branches: | |
- "**/**/**" # only trigger on branches that follow the /x/y/z pattern (branches created from the smatter-cli follow this pattern). To push actual dev changes to this repository, avoid this pattern. or the branch will be deleted. | |
workflow_dispatch: # allows manual triggering | |
jobs: | |
Shuttle-branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract branch name | |
run: echo "BRANCH_NAME=$(echo ${{ github.ref }} | awk -F'heads/' '{print $2}')" >> $GITHUB_ENV | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # avoid shallow clone | |
- name: List files in the repository | |
run: ls ${{ github.workspace }} | |
working-directory: ${{ github.workspace }} | |
- name: Create new branch, set up SSH key, push to smatter-submit, delete old branch | |
run: | | |
BRANCH_NAME=$(echo ${{ github.ref }} | awk -F/ '{print $3}') | |
NEW_BRANCH="${{ env.BRANCH_NAME }}-$(date '+%Y%m%d_%H%M%S')" | |
git checkout -b $NEW_BRANCH | |
mkdir -p ~/.ssh | |
echo "${{ env.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
git remote add smatter-submit-remote [email protected]:Etimo/smatter-submit.git | |
git push smatter-submit-remote $NEW_BRANCH | |
git push -d origin ${{ env.BRANCH_NAME }} | |
- run: echo "Job status ${{ job.status }}." |