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

Switch to new cluster and build credentials #20

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ jobs:
# Docker is preinstalled.
run: nix build .#dockerImage && ./result | docker load

- name: Assume AWS role
uses: aws-actions/configure-aws-credentials@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just commenting early to say that I've been trying to avoid unnecessary use of actions as they're proprietary to GitHub, making the code less portable to other CI systems. They often do little more than a line or two of shell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Even though I do not agree I will take it in consideration.

with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT }}:role/mercury-build-role
aws-region: ${{ env.AWS_REGION }}

- name: Push
run: |
nix develop .#ops -c \
Expand All @@ -33,31 +39,26 @@ jobs:
docker tag mercury "$REPO":latest
docker push --all-tags "$REPO"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_PUSHER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_PUSHER }}
REPO: 060568373025.dkr.ecr.us-west-2.amazonaws.com/mercury
REPO: ${{ vars.AWS_ACCOUNT }}.dkr.ecr.us-west-2.amazonaws.com/mercury

- name: Deploy
run: |
# Force a new deployment, implicitly utilising the new image on the
# same `latest` image tag.
nix develop .#ops -c \
aws ecs update-service --no-cli-pager \
--cluster shared-cluster-staging \
--cluster ${{ vars.TOOLS_CLUSTER }} \
--service mercury-service \
--force-new-deployment
nix develop .#ops -c \
aws ecs wait services-stable \
--cluster shared-cluster-staging \
--cluster ${{ vars.TOOLS_CLUSTER }} \
--services mercury-service
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEPLOYER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEPLOYER }}

# This (emphasis on `--fail-with-body`) acts as a sort of final E2E test.
- name: Notify (Test)
run: |
curl https://mercury.proxy.unsplash.com/api/v1/slack --fail-with-body -X POST \
curl ${{ vars.MERCURY_ENDPOINT }}/api/v1/slack --fail-with-body -X POST \
--oauth2-bearer '${{ secrets.MERCURY_SLACK_TOKEN }}' \
-d channel=playground \
-d title='🚀 Mercury' \
Expand Down