Skip to content

Commit fea016a

Browse files
committed
2021-09-09 16:13:35
1 parent ce49403 commit fea016a

3 files changed

Lines changed: 48 additions & 24 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ RUN apt update && apt install --yes ca-certificates
1010

1111
COPY sources-list /etc/apt/sources.list
1212
COPY *.sh /
13-
RUN apt update && apt install --yes bash git git-lfs tar build-essential fakeroot devscripts
13+
RUN apt update && apt install --yes bash curl git git-lfs tar build-essential fakeroot devscripts
1414

1515
ENTRYPOINT ["/entrypoint.sh"]

action.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,33 @@ inputs:
1111
repo_dst:
1212
description: "Repository (destination)"
1313
required: true
14-
user:
15-
description: "User"
14+
user_name:
15+
description: "User Name"
1616
required: true
17-
email:
18-
description: "E-mail"
17+
user_email:
18+
description: "User E-mail"
1919
required: true
20-
token:
21-
description: "Token"
20+
user_token:
21+
description: "User Token"
2222
required: true
23+
obs_token:
24+
description: "OBS Token"
25+
required: false
26+
obs_project:
27+
description: "OBS Project"
28+
required: false
29+
obs_package:
30+
description: "OBS Package"
31+
required: false
2332
runs:
2433
using: "docker"
2534
image: "Dockerfile"
2635
args:
2736
- ${{ inputs.repo_src }}
2837
- ${{ inputs.repo_dst }}
29-
- ${{ inputs.user }}
30-
- ${{ inputs.email }}
31-
- ${{ inputs.token }}
38+
- ${{ inputs.user_name }}
39+
- ${{ inputs.user_email }}
40+
- ${{ inputs.user_token }}
41+
- ${{ inputs.obs_token }}
42+
- ${{ inputs.obs_project }}
43+
- ${{ inputs.obs_package }}

build.sh

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
# Vars.
44
REPO_SRC="${1}"
55
REPO_DST="${2}"
6-
USER="${3}"
7-
EMAIL="${4}"
8-
TOKEN="${5}"
6+
USER_NAME="${3}"
7+
USER_EMAIL="${4}"
8+
USER_TOKEN="${5}"
9+
OBS_TOKEN="${6}"
10+
OBS_PROJECT="${7}"
11+
OBS_PACKAGE="${8}"
912

1013
# Apps.
14+
curl="$( command -v curl )"
1115
date="$( command -v date )"
1216
debuild="$( command -v debuild )"
1317
git="$( command -v git )"
@@ -19,42 +23,50 @@ d_src="/root/git/repo_src"
1923
d_dst="/root/git/repo_dst"
2024

2125
# Git config.
22-
${git} config --global user.email "${EMAIL}"
23-
${git} config --global user.name "${USER}"
26+
${git} config --global user.name "${USER_NAME}"
27+
${git} config --global user.email "${USER_EMAIL}"
2428
${git} config --global init.defaultBranch 'main'
2529

2630
_timestamp() {
2731
${date} -u '+%Y-%m-%d %T'
2832
}
2933

3034
# Get repos.
31-
get() {
32-
SRC="https://${USER}:${TOKEN}@${REPO_SRC#https://}"
33-
DST="https://${USER}:${TOKEN}@${REPO_DST#https://}"
35+
git_clone() {
36+
SRC="https://${USER_NAME}:${USER_TOKEN}@${REPO_SRC#https://}"
37+
DST="https://${USER_NAME}:${USER_TOKEN}@${REPO_DST#https://}"
3438

3539
${git} clone "${SRC}" "${d_src}" \
3640
&& ${git} clone "${DST}" "${d_dst}"
3741
}
3842

39-
build() {
43+
pkg_build() {
4044
pushd "${d_src}/_build" || exit 1
4145
${debuild} -us -uc -i -d -S && popd || exit 1
4246
}
4347

44-
move() {
48+
pkg_move() {
4549
for i in _service README.md LICENSE *.tar.* *.dsc *.build *.buildinfo *.changes; do
46-
${rm} -fv "${d_dst}"/"${i}"
47-
${mv} -fv "${d_src}"/"${i}" "${d_dst}" || exit 1
50+
${rm} -fv "${d_dst}"/${i}
51+
${mv} -fv "${d_src}"/${i} "${d_dst}" || exit 1
4852
done
4953
}
5054

51-
push() {
55+
git_push() {
5256
ts="$( _timestamp )"
5357

5458
pushd "${d_dst}" || exit 1
5559
${git} add . && ${git} commit -a -m "BUILD: ${ts}" && ${git} push
5660
}
5761

58-
get && build && move && push
62+
obs_trigger(){
63+
if [[ -z "${OBS_TOKEN}" ]]; then
64+
${curl} curl -H "Authorization: Token ${OBS_TOKEN}" -X POST "https://build.opensuse.org/trigger/runservice?project=${OBS_PROJECT}&package=${OBS_PACKAGE}"
65+
else
66+
echo "OBS_TOKEN not set!"
67+
fi
68+
}
69+
70+
git_clone && pkg_build && pkg_move && git_push && obs_trigger
5971

6072
exit 0

0 commit comments

Comments
 (0)