Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/oxford migration #527

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
16 changes: 10 additions & 6 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"dry-run": true,
"verbose": 2,
Expand All @@ -10,14 +11,17 @@
"commitMessage": "Release v${version}",
"tagAnnotation": "Release v${version}",
"requireCleanWorkingDir": false,
"commit": false,
"push": false,
"tag": false
"commit": true,
"push": true,
"tag": true
},
"github": {
"release": false,
"gitlab": {
"release": true,
"sshKey": "/root/.ssh/id_rsa",
"tokenRef": "GITLAB_TOKEN",
"tokenHeader": "private-token",
"skipChecks": true,
"releaseName": "v${version}",
"tokenRef": "GITHUB_ACCESS_TOKEN",
"assets": "IDS-*.zip"
},
"npm": {
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ AWS_SECRET_ACCESS_KEY=
NPM_TOKEN=""
GITHUB_ACCESS_TOKEN=
DOCS_API_KEY=

# specify the semantic version target X.X.X
RELEASE_INCREMENT=minor

RELEASEIT_FLAGS="--dry-run=true"
DRY_RUN=
BRANCH=
```

Then `make build`.
Expand Down
20 changes: 12 additions & 8 deletions cd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:18

WORKDIR /usr/src

Expand All @@ -12,17 +12,21 @@ RUN apt-get -y update \
zip \
git \
wget \
curl \
awscli
curl

RUN npm install npm-cli-login@1.0.0 -g \
&& npm install release-it@14.11.7 -g \
&& npm install aws-sdk@2.1030.0 -g
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip ./aws

RUN curl -L "https://gitlab.com/gitlab-org/cli/-/releases/v1.41.0/downloads/glab_1.41.0_Linux_x86_64.tar.gz" -o "glab.tar.gz" && \
tar -xvf glab.tar.gz && \
cp bin/glab /usr/local/bin/glab && \
chmod +x /usr/local/bin/glab && \
rm -rf glab.tar.gz bin

RUN mkdir -p /root/.ssh && touch /root/.ssh/config
RUN echo "[url \"git@github.com:\"]\n\tinsteadOf = https://github.com/" >> /root/.gitconfig
RUN echo "StrictHostKeyChecking no " > /root/.ssh/config
RUN git config --global url."https://{token}:@github.com/".insteadOf "https://github.com/"

COPY ./run.sh run.sh
RUN chmod +x run.sh
Expand Down
32 changes: 7 additions & 25 deletions cd/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ORGANIZATION = hookandloop
CONTAINER = design-system-builder
VERSION = 0.1.0
VERSION = 0.2.0

ifneq (,$(wildcard ./.env))
include .env
Expand All @@ -9,40 +9,22 @@ endif

.PHONY: build

all-image : build-image push-image
all : build push

build-image :
docker build -t $(ORGANIZATION)/$(CONTAINER):$(VERSION) .
build :
docker build --platform linux/amd64 \
-t $(ORGANIZATION)/$(CONTAINER):$(VERSION) .

push-image :
push :
docker push $(ORGANIZATION)/$(CONTAINER):$(VERSION)

build :
docker run --rm --name $(CONTAINER) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \
--env NPM_TOKEN=${NPM_TOKEN} \
--env DOCS_API_KEY=${DOCS_API_KEY} \
--env RELEASE_INCREMENT=${RELEASE_INCREMENT} \
--env RELEASEIT_FLAGS=${RELEASEIT_FLAGS} \
--env BRANCH=${BRANCH} \
--env REPO_OWNER_NAME=${REPO_OWNER_NAME} \
-v ${PWD}/.gitconfig:/root/.gitconfig \
-v ${PWD}/build:/root/design-system \
-v ${PWD}/run.sh:/usr/src/run.sh \
$(ORGANIZATION)/$(CONTAINER):$(VERSION)

shell :
docker run -it --rm --name $(CONTAINER) \
--entrypoint /bin/sh \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \
--env NPM_TOKEN=${NPM_TOKEN} \
--env DOCS_API_KEY=${DOCS_API_KEY} \
--env RELEASE_INCREMENT=${RELEASE_INCREMENT} \
--env RELEASEIT_FLAGS=${RELEASEIT_FLAGS} \
--env DRY_RUN=${DRY_RUN} \
--env BRANCH=${BRANCH} \
--env REPO_OWNER_NAME=${REPO_OWNER_NAME} \
-v ${PWD}/.gitconfig:/root/.gitconfig \
Expand Down
47 changes: 16 additions & 31 deletions cd/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/bin/bash

# This script runs inside of a docker container on start as a
# kubernetes job. AWS permissions are controlled by a role setup
# in kubernetes. To run this locally, use the "make build" command
# with proper environment variables set in .env file.
set -e

export TERM=xterm
Expand All @@ -20,19 +15,20 @@ check_required_vars()
}

check_required_vars \
GITHUB_ACCESS_TOKEN \
NPM_TOKEN \
BRANCH \
REPO_OWNER_NAME
REPO_OWNER_NAME \
DRY_RUN

npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"

_RELEASE_INCREMENT=${RELEASE_INCREMENT:-}
_ROOT_DIR=/root/design-system

rm -fr $_ROOT_DIR/{..?*,.[!.]*,*} 2>/dev/null

git clone https://$GITHUB_ACCESS_TOKEN@github.com/$REPO_OWNER_NAME.git $_ROOT_DIR
git clone $REPO_OWNER_NAME $_ROOT_DIR
cd $_ROOT_DIR
git remote set-url origin https://${GITHUB_ACCESS_TOKEN}@github.com/infor-design/design-system.git

git fetch --all
git checkout $BRANCH > /dev/null
Expand All @@ -46,35 +42,24 @@ npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
npm install
npm run build

if [ -n "$RELEASEIT_FLAGS" ];
then
release-it $RELEASEIT_FLAGS --config .release-it.json --ci -- $_RELEASE_INCREMENT
fi

if [ -z $VERSION ]
then
VERSION=$(node -p "require('./package.json').version")
fi

if [[ "$RELEASEIT_FLAGS" == *"--dry-run=true"* ]];
then
cd $_ROOT_DIR/dist && \
zip -r $_ROOT_DIR/dry-run-dist-$VERSION.zip .
fi
git tag "${VERSION}"

if [[ "$RELEASEIT_FLAGS" == *"--dry-run=false"* ]];
if [ "$DRY_RUN" = "true" ]
then
cd $_ROOT_DIR/dist && {
aws s3 sync . s3://ids-com/docs/ids-identity/$VERSION/
aws s3 sync . s3://ids-com-staging/docs/ids-identity/$VERSION/
}
echo "Skipping git push and npm publish in dry run mode."
npm publish --access public --dry-run
exit 0
fi

ZIP_FILES=`find $_ROOT_DIR -iname \*.zip`
git push origin "${VERSION}"
npm publish --access public

echo "Found zip files: $ZIP_FILES"

for file in $ZIP_FILES; do
aws s3 cp "$file" "s3://infor-design-assets-downloads/archives/`basename $file`"
echo "public link to $file: https://infor-design-assets-downloads.s3.amazonaws.com/archives/`basename $file`"
done
cd $_ROOT_DIR/dist && {
aws s3 sync . s3://ids-com/docs/ids-identity/$VERSION/
aws s3 sync . s3://ids-com-staging/docs/ids-identity/$VERSION/
}
Loading
Loading