2023-07-16 02:01:47
This commit is contained in:
parent
ea72058771
commit
29efa753cd
|
@ -0,0 +1,13 @@
|
|||
# Contributing
|
||||
|
||||
- Feedback, wishes and suggestions can be sent by email.
|
||||
- Constructive criticism, bug descriptions and other reports are welcome.
|
||||
- Email: mail@ihub.to
|
||||
|
||||
## Sources
|
||||
|
||||
- [**GitHub**](https://github.com/ghastore)
|
||||
- [GitLab](https://gitlab.com/ghastore) (MIRROR)
|
||||
- [Codeberg](https://codeberg.org/ghastore) (MIRROR)
|
||||
- [MosHub](https://hub.mos.ru/ghastore) (MIRROR)
|
||||
- [Git.Org.Ru](https://git.org.ru/ghastore) (MIRROR)
|
|
@ -0,0 +1,12 @@
|
|||
FROM alpine
|
||||
|
||||
LABEL "name"="GPG Builder"
|
||||
LABEL "description"="GitHub Action for build GPG files."
|
||||
LABEL "maintainer"="iHub TO <mail@ihub.to>"
|
||||
LABEL "repository"="https://github.com/ghastore/build-gpg.git"
|
||||
LABEL "homepage"="https://github.com/ghastore"
|
||||
|
||||
COPY *.sh /
|
||||
RUN apk add --no-cache bash curl git git-lfs gpg
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 GitHub Actions Store
|
||||
Copyright (c) 2023 iHub TO <https://ihub.to>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
name: "GPG Builder"
|
||||
author: "iHub TO <mail@ihub.to>"
|
||||
description: "GitHub Action for build GPG files."
|
||||
branding:
|
||||
icon: ""
|
||||
color: ""
|
||||
inputs:
|
||||
git_repo:
|
||||
description: "Git Repository"
|
||||
required: true
|
||||
git_user:
|
||||
description: "Git User"
|
||||
required: true
|
||||
git_email:
|
||||
description: "Git E-mail"
|
||||
required: true
|
||||
git_token:
|
||||
description: "Git Token"
|
||||
required: true
|
||||
gpg_url:
|
||||
description: "GPG URL"
|
||||
required: true
|
||||
gpg_name:
|
||||
description: "GPG Name"
|
||||
required: true
|
||||
gpg_cmd:
|
||||
description: "GPG Command"
|
||||
required: false
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
args:
|
||||
- ${{ inputs.git_repo }}
|
||||
- ${{ inputs.git_user }}
|
||||
- ${{ inputs.git_email }}
|
||||
- ${{ inputs.git_token }}
|
||||
- ${{ inputs.gpg_url }}
|
||||
- ${{ inputs.gpg_name }}
|
|
@ -0,0 +1,114 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# CONFIGURATION.
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
# Vars.
|
||||
GIT_REPO="${1}"
|
||||
GIT_USER="${2}"
|
||||
GIT_EMAIL="${3}"
|
||||
GIT_TOKEN="${4}"
|
||||
GPG_URL="${5}"
|
||||
GPG_NAME="${6}"
|
||||
GPG_CMD="${7}"
|
||||
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
|
||||
|
||||
# Apps.
|
||||
date="$( command -v date )"
|
||||
git="$( command -v git )"
|
||||
curl="$( command -v curl )"
|
||||
gpg="$( command -v gpg )"
|
||||
|
||||
# Dirs.
|
||||
d_src="/root/git/repo"
|
||||
|
||||
# Git.
|
||||
${git} config --global user.name "${GIT_USER}"
|
||||
${git} config --global user.email "${GIT_EMAIL}"
|
||||
${git} config --global init.defaultBranch 'main'
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# INITIALIZATION.
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
init() {
|
||||
ts="$( _timestamp )"
|
||||
|
||||
clone \
|
||||
&& build \
|
||||
&& push
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# GIT: CLONE REPOSITORY.
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
clone() {
|
||||
echo "--- [GIT] CLONE: ${GIT_REPO#https://}"
|
||||
|
||||
local src="https://${GIT_USER}:${GIT_TOKEN}@${GIT_REPO#https://}"
|
||||
${git} clone "${src}" "${d_src}"
|
||||
|
||||
echo "--- [GIT] LIST: '${d_src}'"
|
||||
ls -1 "${d_src}"
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# GPG: BUILD FILES.
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
build() {
|
||||
echo "--- [GPG] BUILD"
|
||||
_pushd "${d_src}" || exit 1
|
||||
|
||||
if [[ "${GPG_CMD}" == "dearmor" ]]; then
|
||||
${curl} -X GET -A "${USER_AGENT}" -fsSL "${GPG_URL}" | ${gpg} --batch --yes --dearmor -o "${GPG_NAME}"
|
||||
else
|
||||
${curl} -X GET -A "${USER_AGENT}" -fsSL -o "${GPG_NAME}" "${GPG_URL}"
|
||||
fi
|
||||
|
||||
_popd || exit 1
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# GIT: PUSH GPG TO GPG STORE REPOSITORY.
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
push() {
|
||||
echo "--- [GIT] PUSH: '${d_src}' -> '${GIT_REPO#https://}'"
|
||||
_pushd "${d_src}" || exit 1
|
||||
|
||||
# Commit build files & push.
|
||||
echo "Commit build files & push..."
|
||||
${git} add . \
|
||||
&& ${git} commit -a -m "BUILD: ${ts}" \
|
||||
&& ${git} push
|
||||
|
||||
_popd || exit 1
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# ------------------------------------------------< COMMON FUNCTIONS >------------------------------------------------ #
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
# Pushd.
|
||||
_pushd() {
|
||||
command pushd "$@" > /dev/null || exit 1
|
||||
}
|
||||
|
||||
# Popd.
|
||||
_popd() {
|
||||
command popd > /dev/null || exit 1
|
||||
}
|
||||
|
||||
# Timestamp.
|
||||
_timestamp() {
|
||||
${date} -u '+%Y-%m-%d %T'
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
# -------------------------------------------------< INIT FUNCTIONS >------------------------------------------------- #
|
||||
# -------------------------------------------------------------------------------------------------------------------- #
|
||||
|
||||
init "$@"; exit 0
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
bash -c "/build.sh $*"
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue