Skip to content

Commit

Permalink
use secret variables for auth (#859)
Browse files Browse the repository at this point in the history
* use secret variables for auth
  • Loading branch information
dmitry-sinina authored Jan 29, 2021
1 parent c66c331 commit b72d98c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/nightly-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ jobs:
CDR_DB_HOST: db
CDR_DB_PORT: 5432
- name: Upload package to ${{github.ref}} repo
run: ci/deploy.sh "$API_ENDPOINT" buster nightly main /build/*.deb
env:
PKG_API_BASE: ${{secrets.PKG_API_BASE}}
run: ci/deploy.sh buster nightly main /build/*.deb

4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ jobs:
CDR_DB_HOST: db
CDR_DB_PORT: 5432
- name: Upload package to ${{github.ref}} repo
run: ci/deploy.sh "$API_ENDPOINT" buster ${{github.ref}} main /build/*.deb
env:
PKG_API_BASE: ${{secrets.PKG_API_BASE}}
run: ci/deploy.sh buster ${{github.ref}} main /build/*.deb

19 changes: 8 additions & 11 deletions ci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
set -e

function usage(){
echo -e "usage: $0 api_base release distribution component deb_file1 [ deb_file2 ...]"
echo -e "usage: $0 release distribution component deb_file1 [ deb_file2 ...]"
exit 1
}

[ -z "$1" ] && echo -e "\nmissed api base\n" && usage
[ -z "$2" ] && echo -e "\nmissed release\n" && usage
[ -z "$3" ] && echo -e "\nmissed distribution\n" && usage
[ -z "$4" ] && echo -e "\nmissed component\n" && usage
[ -z "$5" ] && echo -e "\nmissed package\n" && usage
[ -z "$1" ] && echo -e "\nmissed release\n" && usage
[ -z "$2" ] && echo -e "\nmissed distribution\n" && usage
[ -z "$3" ] && echo -e "\nmissed component\n" && usage
[ -z "$4" ] && echo -e "\nmissed package\n" && usage

api_base="$1"
shift
release="$1"
shift
distr="$1"
Expand All @@ -34,12 +31,12 @@ function fail {

for file in $files; do
echo -e "\n\e[33m> upload pkg \e[39m $file\n"
curl -sSfF file=@"$file" "${api_base}/files/$dir" || fail "can't upload pkg file $file"
curl -sSfF file=@"$file" "${PKG_API_BASE}/files/$dir" || fail "can't upload pkg file $file"
done

echo -e "\n\e[33m> add pkg to repo $repo\e[39m\n"
curl -sSf -X POST "${api_base}/repos/$repo/file/$dir" || fail "can't add pkg to repo"
curl -sSf -X POST "${PKG_API_BASE}/repos/$repo/file/$dir" || fail "can't add pkg to repo"

echo -e "\n\e[33m> update publish $release/$distr \e[39m\n"
curl -sSf -X PUT -H 'Content-Type: application/json' --data '{ "Signing": {"PassphraseFile":"/home/pkg/gpg_pass"} }' "${api_base}/publish/${release}/${distr}" || fail "can't publish"
curl -sSf -X PUT -H 'Content-Type: application/json' --data '{ "Signing": {"PassphraseFile":"/home/pkg/gpg_pass"} }' "${PKG_API_BASE}/publish/${release}/${distr}" || fail "can't publish"

0 comments on commit b72d98c

Please sign in to comment.