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

Srh/ebs deployment bootstrap #4

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
31dd681
added ci artifact making with cd (not finished)
42kbit Dec 29, 2023
8b6b46c
added explicit environment annotation
42kbit Dec 29, 2023
0bd21ed
fixed some dumbass env* variables in github action not registering
42kbit Dec 29, 2023
0236e2b
fixed missing aws auth region parameter to aws-action/configure-aws-c…
42kbit Dec 29, 2023
9fe3c47
fixed misstyped aws-secret-access-key-id -> aws-secret-access-key
42kbit Dec 29, 2023
044c2fa
fixed artifact path hiding secret, which led to invalid formatted s3 …
42kbit Dec 29, 2023
4a80ec7
moved artifacts to more inner scope
42kbit Dec 29, 2023
fdae59c
fixed env not being able to read itself (github actions bug)
42kbit Dec 29, 2023
bc2ca4d
fixed (once again) github actions inability to read env within env
42kbit Dec 29, 2023
5a7f8bc
fixed yaml multiline string indentation
42kbit Dec 29, 2023
81de22b
ok... on more try on this env thing...
42kbit Dec 29, 2023
b6293b8
revert commit 81de22b
42kbit Dec 29, 2023
d661520
added cd dependency on ci
42kbit Dec 29, 2023
7359a2f
made cd yaml callable
42kbit Dec 29, 2023
021b5d2
removed deps from cd callable workflow
42kbit Dec 29, 2023
41e309d
secrets are passed through args now
42kbit Dec 29, 2023
bad653a
fixed inputs with secrets mixing
42kbit Dec 29, 2023
4d23636
secrets changed to inherit, since it seems like regular passing wont …
42kbit Dec 30, 2023
a4acc5b
definition of secrets is applied
42kbit Dec 30, 2023
1c6a61c
added explicit branch annotation
42kbit Dec 30, 2023
352f336
bootstrap commit of ebs deployment workflow
42kbit Dec 30, 2023
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
38 changes: 38 additions & 0 deletions .github/workflows/3_webserver_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
test_code:
runs-on: ubuntu-latest
name: Run python tests
environment: prod

steps:
- uses: actions/checkout@v4 # does git clone into runner

Expand All @@ -47,3 +49,39 @@ jobs:

# you can also run lint tests, to ensure that the project matches
# your desired codestyle, but well pass it for now.

make_artifact:
runs-on: ubuntu-latest
needs: [test_code] # may not be required i belive, if we want this
# to run in paralel, but i'll do it anyway to make less jobs
environment: prod
env:
ARTIFACT_EXCLUDE: ./.git*
ARTIFACT_NAME: webserver-artifact-${{ github.sha }}.zip
# github doesn't resolve env inside env sadly (or im dumb idk)
ARTIFACT_S3_PATH: >-
${{ secrets.ARTIFACT_S3_BUCKET_NAME }}/webserver-artifact-${{ github.sha }}.zip

steps:
- uses: actions/checkout@v4

- name: Zip archive
run: zip -r ${{ env.ARTIFACT_NAME }} ./ -x ${{ env.ARTIFACT_EXCLUDE }}

- name: Authenticate to aws account
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Copy artifact to S3 bucket
run: aws s3 cp "$ARTIFACT_NAME" "s3://$ARTIFACT_S3_PATH"

# artifact is made, job here is done, next - CD pipeline will deploy it.

# https://stackoverflow.com/a/71158878
use_webserver_cd:
needs: [make_artifact]
uses: ./.github/workflows/webserver_cd_aws_ebs.yaml@${{ github.head_ref || github.ref_name }}
secrets: inherit
29 changes: 29 additions & 0 deletions .github/workflows/webserver_cd_aws_ebs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy webserver to AWS elastic beanstalk (callable)

on:
workflow_call:
secrets:
AWS_ACCESS_KEY:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_REGION:
required: true

jobs:
deploy:
name: Deploy to elastic beanstalk

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Authenticate to aws account
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Deploying to AWS EBA
run: echo "Deploying..."