This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pennsignals/add_prod_path
Add prod path
- Loading branch information
Showing
6 changed files
with
41 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,60 +13,10 @@ jobs: | |
steps: | ||
- name: checkout | ||
uses: actions/[email protected] | ||
|
||
- name: version | ||
run: | | ||
# Tagged release | ||
if [[ ${{ github.ref }} == refs/tags/* ]]; then | ||
# Strip git ref prefix from $VERSION | ||
TAGNAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
VERSION=$(echo $TAGNAME | sed -e 's/^v//') | ||
else | ||
VERSION=${{ github.sha }} | ||
fi | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
echo "GITHUB_REF=$GITHUB_REF" >> $GITHUB_ENV | ||
# write .env to export ENV VARIABLES as artifacts for use in other workflow_run runs | ||
echo "PUBLISH_VERSION=$VERSION" >> .env | ||
echo "PUBLISH_GITHUB_REF=$GITHUB_REF" >> .env | ||
echo "Version: $VERSION" | ||
export DOCKER_BUILDKIT=1 | ||
|
||
- name: publish | ||
run: | | ||
VERSION="${{ env.VERSION }}" | ||
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | ||
# build and run the docker images | ||
docker-compose -f docker-compose.build.yml up --no-start | ||
# get all built IDs | ||
IMAGE_IDs=$(docker-compose -f docker-compose.build.yml images -q) | ||
echo "IMAGE_IDs: $IMAGE_IDs" | ||
while read -r IMAGE_ID; do | ||
echo "IMAGE_ID: $IMAGE_ID" | ||
# get the name label | ||
NAME=$(basename ${{ github.repository }}).$(docker inspect --format '{{ index .Config.Labels.name }}' $IMAGE_ID) | ||
PUSH="docker.pkg.github.com/${{ github.repository }}/$NAME:$VERSION" | ||
# tag and push | ||
docker tag $IMAGE_ID $PUSH | ||
docker push $PUSH | ||
done <<< "$IMAGE_IDs" | ||
# Upload reference as artifact to pass to deploy | ||
- name: upload .env | ||
uses: actions/upload-artifact@v2 | ||
id: publish | ||
uses: pennsignals/[email protected] | ||
with: | ||
name: env | ||
path: .env | ||
docker_compose: 'docker-compose.build.yml' | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
ARG CONSUL_VERSION=1.8.5 | ||
ARG YQ_VERSION=3.4.1 | ||
ARG BINARY=linux_amd64 | ||
|
||
FROM debian:10.6-slim as consul | ||
|
||
LABEL name=consul | ||
|
||
ARG VERSION="3.4.1" | ||
ARG BINARY="yq_linux_amd64" | ||
ARG CONSUL_VERSION | ||
ARG YQ_VERSION | ||
ARG BINARY | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
curl \ | ||
wget | ||
wget \ | ||
unzip | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ADD ./src/submit_to_consul.sh /scripts/submit_to_consul.sh | ||
|
||
# install yq | ||
RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq &&\ | ||
chmod +x /usr/bin/yq | ||
# download yq and consul | ||
RUN wget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_${BINARY} &&\ | ||
wget -qO /tmp/consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_${BINARY}.zip | ||
|
||
# install yq and consul | ||
RUN chmod +x /usr/bin/yq &&\ | ||
unzip /tmp/consul.zip -d /usr/local/bin/ | ||
|
||
ENTRYPOINT [ "/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
#!/bin/sh | ||
|
||
# echo all the variabls | ||
echo "CONSUL_ADDR: $CONSUL_ADDR" | ||
echo "CONSUL_HTTP_ADDR: $CONSUL_HTTP_ADDR" | ||
echo "DEPLOY_CONFIG: $DEPLOY_CONFIG" | ||
echo "ENV: $ENV" | ||
|
||
# parse DEPLOY_CONFIG file and build VAULT_PATH | ||
|
||
# Use input environment parameter if given | ||
CONFIG_ENV=$(yq read $DEPLOY_CONFIG 'deploy') | ||
DEPLOY="$ENV:-$CONFIG_ENV" | ||
|
||
CONSUL_PATH=$(yq read $DEPLOY_CONFIG 'organization')/$(yq read $DEPLOY_CONFIG 'project') | ||
# parse DEPLOY_CONFIG file and build PATH | ||
ORGANIZATION=$(yq read $DEPLOY_CONFIG 'organization') | ||
PROJECT=$(yq read $DEPLOY_CONFIG 'project') | ||
SERVICES=$(yq read --printMode p $DEPLOY_CONFIG 'services.*.' | cut -f2 -d '.') | ||
REGEX=$(yq read $DEPLOY_CONFIG 'template.configs.regex') | ||
|
||
# go through each SERVICE | ||
for SERVICE in $(echo $SERVICES | sed "s/,/ /g"); do | ||
echo "Service: $SERVICE" | ||
|
||
# build CONSUL PATH | ||
CONFIGS_PATH=$(yq read $DEPLOY_CONFIG services.$SERVICE.location)/$(yq read $DEPLOY_CONFIG template.configs.location) | ||
|
||
# find all config files matching regex file extension and deploy environement (example staging.yml) | ||
CONFIG_FILES=$(find "${CONFIGS_PATH}" -type f -regextype posix-extended -regex "${REGEX}" -and -regex ".*.${DEPLOY}.*") | ||
# get file based on environenment (staging / production) | ||
CONFIG_FILE=$(yq read $DEPLOY_CONFIG services.$SERVICE.location)/$(yq read $DEPLOY_CONFIG template.configs.location)/$(yq read $DEPLOY_CONFIG services.$SERVICE.configuration.local.$ENV) | ||
# set filename to .configuration.name | ||
FILE_NAME=$(yq read $DEPLOY_CONFIG services.$SERVICE.configuration.name) | ||
|
||
# submit all found config files to consul | ||
echo "/scripts/submit_to_consul.sh --path ${CONSUL_PATH} --address ${CONSUL_ADDR} --deploy ${DEPLOY} --service "${SERVICE}" ${CONFIG_FILES}" | ||
/scripts/submit_to_consul.sh --path "${CONSUL_PATH}" --address "${CONSUL_ADDR}" --deploy "${DEPLOY}" --service "${SERVICE}" "${CONFIG_FILES}" | ||
# submit to consul | ||
consul kv put $ORGANIZATION/$PROJECT/$SERVICE/$FILE_NAME @$CONFIG_FILE | ||
|
||
done |
This file was deleted.
Oops, something went wrong.