Skip to content

Commit 5adbc9d

Browse files
shovnikAzfaar Qureshi
authored andcommitted
Added deploy and deploy-website jobs, rebased and addressed requested changes
Signed-off-by: Shovnik Bhattacharya <[email protected]> adding comment explaining ssh in web_deploy job Signed-off-by: Azfaar Qureshi <[email protected]>
1 parent e16673f commit 5adbc9d

File tree

2 files changed

+106
-20
lines changed

2 files changed

+106
-20
lines changed

.circleci/config.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,26 @@ workflows:
3232
<<: *filters
3333
- build:
3434
<<: *filters
35-
- deploy_website:
36-
requires:
37-
- test
38-
- build
39-
filters:
40-
branches:
41-
only: master
42-
- deploy:
43-
requires:
44-
- build
45-
- test
46-
- lint
47-
- integration
48-
- integration-configs-db
49-
filters:
50-
branches:
51-
only: master
52-
tags:
53-
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
35+
# Disabling deploy jobs to prevent deploying twice while Github Actions Workflows are Running
36+
# - deploy_website:
37+
# requires:
38+
# - test
39+
# - build
40+
# filters:
41+
# branches:
42+
# only: master
43+
# - deploy:
44+
# requires:
45+
# - build
46+
# - test
47+
# - lint
48+
# - integration
49+
# - integration-configs-db
50+
# filters:
51+
# branches:
52+
# only: master
53+
# tags:
54+
# only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
5455

5556
commands:
5657
install-docker:

.github/workflows/test-build-deploy.yml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ jobs:
7373
run: |
7474
touch build-image/.uptodate
7575
make BUILD_IN_CONTAINER=false web-build
76+
- name: Upload Website Artifact
77+
uses: actions/upload-artifact@v2
78+
with:
79+
name: website public
80+
path: website/public/
7681
- name: Save Images
7782
run: |
7883
mkdir /tmp/images
@@ -160,7 +165,87 @@ jobs:
160165
- name: Extract Docker Images Archive
161166
run: tar -xvf images.tar -C /
162167
- name: Run Integration Configs Tests
168+
# Github Actions does not support TTY in their default runners yet
163169
run: |
164170
touch build-image/.uptodate
165171
MIGRATIONS_DIR=$(pwd)/cmd/cortex/migrations
166-
make BUILD_IMAGE=quay.io/cortexproject/build-image:upgrade-build-image-debian-491e60715-WIP TTY='' configs-integration-test
172+
make BUILD_IMAGE=quay.io/cortexproject/build-image:upgrade-build-image-debian-491e60715-WIP TTY='' configs-integration-test
173+
174+
deploy_website:
175+
needs: [build, test]
176+
if: github.ref == 'refs/heads/master' && github.repository == 'cortexproject/cortex'
177+
runs-on: ubuntu-latest
178+
container:
179+
image: quay.io/cortexproject/build-image:upgrade-build-image-debian-491e60715-WIP
180+
steps:
181+
- name: Checkout Repo
182+
uses: actions/checkout@v2
183+
with:
184+
# web-deploy script requires repo to be cloned with ssh for some commands to work
185+
ssh-key: ${{ secrets.WEBSITE_DEPLOY_SSH_PRIVATE_KEY }}
186+
- name: Sym Link Expected Path to Workspace
187+
run: |
188+
mkdir -p /go/src/github.com/cortexproject/cortex
189+
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/cortex
190+
- name: Download Website Artifact
191+
uses: actions/download-artifact@v2
192+
with:
193+
name: website public
194+
path: website/public
195+
- name: Setup SSH Keys and known_hosts for Github Authentication to Deploy Website
196+
run: |
197+
mkdir -p ~/.ssh
198+
ssh-keyscan github.com >> ~/.ssh/known_hosts
199+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
200+
ssh-add - <<< "${{ secrets.WEBSITE_DEPLOY_SSH_PRIVATE_KEY }}"
201+
env:
202+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
203+
shell: bash
204+
- name: Deploy Website
205+
# SSH is used to authentricate with Github because web-deploy script uses git to checkout and push to gh-pages
206+
run: make BUILD_IN_CONTAINER=false web-deploy
207+
env:
208+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
209+
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
210+
211+
deploy:
212+
needs: [build, test, lint, integration, integration-configs-db]
213+
if: github.ref == 'refs/heads/master' && github.repository == 'cortexproject/cortex'
214+
runs-on: ubuntu-latest
215+
container:
216+
image: quay.io/cortexproject/build-image:upgrade-build-image-debian-491e60715-WIP
217+
steps:
218+
- name: Checkout Repo
219+
uses: actions/checkout@v2
220+
- name: Install Docker Client
221+
run: ./.github/workflows/scripts/install-docker.sh
222+
- name: Sym link Expected Path to Workspace
223+
run: |
224+
mkdir -p /go/src/github.com/cortexproject/cortex
225+
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/cortex
226+
- name: Download Docker Images Artifact
227+
uses: actions/download-artifact@v2
228+
with:
229+
name: Docker Images
230+
- name: Extract Docker Images Archive
231+
run: tar -xvf images.tar -C /
232+
- name: Load Images
233+
run: |
234+
ln -s /tmp/images ./docker-images
235+
make BUILD_IN_CONTAINER=false load-images
236+
- name: Deploy
237+
run: |
238+
if [ -n "$DOCKER_REGISTRY_PASSWORD" ]; then
239+
docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD"
240+
fi
241+
if [ -n "$QUAY_PASSWORD" ]; then
242+
docker login -u "$QUAY_REGISTRY_USER" -p "$QUAY_REGISTRY_PASSWORD" quay.io;
243+
fi
244+
IMAGE_TAG=$GIT_TAG ./push-images $NOQUAY
245+
env:
246+
DOCKER_REGISTRY_USER: ${{secrets.DOCKER_REGISTRY_USER}}
247+
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
248+
QUAY_REGISTRY_USER: ${{secrets.QUAY_USER}}
249+
QUAY_REGISTRY_PASSWORD: ${{secrets.QUAY_PASSWORD}}
250+
GIT_TAG: ${{github.event.release.tag_name}}
251+
NOQUAY: ${{secrets.NOQUAY}}

0 commit comments

Comments
 (0)