-
Notifications
You must be signed in to change notification settings - Fork 830
Migrate CircleCI workflows to GitHub Actions (3/3) #3368
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
Conversation
@AzfaarQureshi I've merged the part 2 PR. Could you rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on it! I left few minor comments, but overall LGTM (good job!). Please remember to rebase master
.
As soon as we merge this, the deploy and deploy_website jobs will both run in CircleCI and GitHub actions, effectively deploying the same thing twice. I would suggest to comment out (not remove for now) the deploy and deploy_website trigger from CircleCI so that we'll only run the GitHub actions once (and we'll soon realise if there's any issue, and in case we'll reiterate on it to fix it).
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
with: | ||
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required, contrary to other jobs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a comment for further clarity but to answer your question:
The web-deploy
script assumes the repo to be cloned with .git
rather than https
or else lines like this will return wrong urls. So the ssh key here is required so that web-deploy can correctly interact with github 😄
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | ||
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a code comment to explain that the web-deploy script use git to checkout and push to the github pages repository and we use ssh to authenticate to github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added
with: | ||
name: website public | ||
path: website/public | ||
- name: Setup SSH Keys and known_hosts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- name: Setup SSH Keys and known_hosts | |
- name: Setup SSH Keys and known_hosts used to authenticated to GitHub to deploy website |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amended
mkdir -p ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | ||
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth renaming SSH_PRIVATE_KEY
to WEBSITE_DEPLOY_SSH_PRIVATE_KEY
for clarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
QUAY_PASSWORD: ${{secrets.QUAY_PASSWORD}} | ||
QUAY_USER: ${{secrets.QUAY_USER}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to DOCKER_REGISTRY_*
I would call these env variables QUAY_REGISTRY_PASSWORD
and QUAY_REGISTRY_USER
for clarity.
I know you used the same env variable names from CircleCI pipeline, but since they're just used here we can afford to change them for a better consistency without introducing any breaking change on CircleCI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standardized registry env variable naming
Assuming you will pick my suggestions, I've already setup the following secrets:
I've intentionally not defined |
f9f2597
to
c05fff2
Compare
c05fff2
to
a00ea5f
Compare
Rebased and made all suggested changes @pracucci . I commented out the deploy and deploy-website workflows in CircleCI to avoid deploying twice since they were using the default triggers with restrictions. Let us know if there is anything else we need to change. Thanks for all three reviews! |
a00ea5f
to
5adbc9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Pinging @pstibrany for the 2nd (required) review and then we can merge. In case of any issue, we can easily disable GitHub actions and de-comment CircleCI.
Sounds good, thanks for the update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for all this work! (my comments/questions are not blocking)
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
with: | ||
# web-deploy script requires repo to be cloned with ssh for some commands to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, which commands require ssh?
I don't see anything ssh-specific in web-deploy script, and I think that using HTTPS with token for pushing should work, but I admit that I only gave it a quick look as this comment piqued my interest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current CircleCI workflow also adds a ssh key because git push
expects to communicate over ssh (because of how remote is set here. You are right, we could use HTTPS with a token but that would require modifying web-deploy.sh
to set the remote url with https://cortexproject<TOKEN>@github.com/cortexproject/cortex.git
which would break CircleCI the way it is currently.
As I type this out I realize require
might be a strong word because we could do it over https. Maybe rephrasing the comment as "web-deploy script expects repo to be cloned with" would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated comment!
- name: Setup SSH Keys and known_hosts for Github Authentication to Deploy Website | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do this, since StrictHostKeyChecking=no
is used below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought so too but removing this section causes a could not resolve host: GitHub.com
😞
docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" | ||
fi | ||
if [ -n "$QUAY_PASSWORD" ]; then | ||
docker login -u "$QUAY_REGISTRY_USER" -p "$QUAY_REGISTRY_PASSWORD" quay.io; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like extra semicolon at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included it here because it's in the circleci config as well: https://github.com/cortexproject/cortex/blob/master/.circleci/config.yml#L247
Do you want me to remove the semicolon in GHA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it for consistency for now.
… changes Signed-off-by: Shovnik Bhattacharya <shovnik@amazon.com> adding comment explaining ssh in web_deploy job Signed-off-by: Azfaar Qureshi <azfaarq@amazon.com>
5adbc9d
to
91500cf
Compare
What this PR does
This is PR 3/3 of migrating Cortex's CI from CircleCI to GitHub Actions:
Part 1/3
test-build-deploy
workflow under.github/workflows
lint
test
build
master
or when any PR is opened. However CD jobs will only run on the master branch and will be skipped otherwisePart 2/3
build
integration
integration-config-db
Part 3/3 👈
deploy_website
is dependant onbuild, test
deploy
is dependant onbuild, test, lint, integration, integration-config-db
Which issue(s) this PR fixes:
fixes #3274
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]