-
Notifications
You must be signed in to change notification settings - Fork 12
54 lines (51 loc) · 1.89 KB
/
dev-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
name: publish-dev
on:
push:
branches:
- 'main'
- 'dev'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build-on-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code repository
run: sudo apt-get update && sudo apt-get -y install rsync
- name: Checkout code repository
uses: actions/checkout@v2
- name: Set Variables
id: prep
run: |
COMMIT="${GITHUB_SHA::8}"
echo ::set-output name=commit::${COMMIT}
echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Push to Dev Repo
run: |
MAINNAME="main"
TEMPREPO=$(mktemp -d)
AUTHURL="https://${{ secrets.WORKER_TOKEN }}:[email protected]"
PUBREPO="O-MG/WebFlasher-Test.git"
PUBBRANCH="main"
TMPBRANCH="publish-$(date '+%Y-%m-%d')"
WORKER_USER="omg-builds"
CURRPATH="$(pwd)"
ls
pwd
git config --global user.email [email protected]
git config --global user.name $WORKER_USER
echo "Cloning repo '${PUBREPO}' branch '${PUBBRANCH}' into directory '${TEMPREPO}' via PAT for user ${WORKER_USER}"
git clone --depth 1 "${AUTHURL}/${PUBREPO}" "${TEMPREPO}"
ls -la "${TEMPREPO}"
cd "${TEMPREPO}"
git checkout --orphan "${TMPBRANCH}"
rm -rfv ./*
cp -vrf ${CURRPATH}/* "${TEMPREPO}/"
git add -fA ./
git commit -m "automated publish of release '${{ steps.prep.outputs.commit }}' by ${{ github.actor }} for branch ${{ steps.prep.outputs.branch }}"
git branch -D ${PUBBRANCH}
git branch -m ${PUBBRANCH}
git push -f origin ${PUBBRANCH}
git gc --aggressive --prune=all