Skip to content

Commit ed37f07

Browse files
committed
implementing builder
1 parent 1d19e66 commit ed37f07

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM rust:alpine
2-
3-
RUN curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git cobalt-org/cobalt.rs --crate cobalt
1+
FROM lehmannka/cobalt.rs
42

3+
RUN apt update && apt install -y git
54
COPY ./entrypoint.sh /entrypoint.sh
65

6+
WORKDIR /src/
7+
78
ENTRYPOINT [ "/entrypoint.sh" ]

action.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ inputs:
1111
githubToken:
1212
description: "Personal Access Token with permission to the repository"
1313
required: true
14-
14+
repo:
15+
description: "Repository to push building page"
16+
required: false
17+
branch:
18+
description: "Branch to push building page"
19+
required: false
20+
default: "gh-pages"
21+
cname:
22+
description: "Registry dns name to page"
23+
required: false

entrypoint.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
NC='\e[0m'
6+
BOLD='\e[1m'
7+
UNDERLINE='\e[4m'
8+
BRED='\e[1;4;31m'
9+
IRED='\e[3;31m'
10+
BGREEN='\e[1;32m'
11+
12+
13+
if [ -z "${INPUT_GITHUBTOKEN}" ]; then
14+
echo -e "${BRED}Error:\n${NC} ${IRED}Missing Github Access Token${NC}"
15+
exit 1
16+
fi
17+
18+
if [ "${INPUT_REPO}" ]; then
19+
REPO=${INPUT_REPO}
20+
else
21+
REPO=${GITHUB_REPOSITORY}
22+
fi
23+
24+
REPO_URL="https://x-access-token:${INPUT_GITHUBTOKEN}@github.com/${REPO}.git"
25+
26+
echo -e "${UNDERLINE}Resume${NC}"
27+
echo -e "${BOLD}REPO:${NC} ${REPO}"
28+
echo -e "${BOLD}BRANCH:${NC} ${INPUT_BRANCH}"
29+
[ -n "${INPUT_CNAME}" ] && echo -e "${BOLD}CNAME:${NC} ${INPUT_CNAME}"
30+
31+
echo -e "\n${BOLD}Setting up Git${NC}..."
32+
git config --global user.name "${GITHUB_ACTOR}"
33+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
34+
echo "machine github.com login ${GITHUB_ACTOR} password ${INPUT_GITHUBTOKEN}" > ~/.netrc
35+
36+
echo -e "\nBuilding.."
37+
git clone --depth=1 --single-branch --branch "${INPUT_BRANCH}" "${REPO_URL}" /tmp/build
38+
39+
rm -rf /tmp/build/*
40+
41+
cobalt build
42+
43+
cp -a build/* /tmp/build
44+
45+
cd /tmp/build
46+
47+
[ -n "${INPUT_CNAME}" ] && echo "${INPUT_CNAME}" > CNAME
48+
echo -e " \b${BGREEN}[OK]${NC}"
49+
50+
echo -e "\n\nPuching..."
51+
git add -A && git commit --allow-empty -am "Publishing site at $(date -u)"
52+
git push --force
53+
echo -e " \b${BGREEN}[OK]${NC}"

0 commit comments

Comments
 (0)