Skip to content

Instantly share code, notes, and snippets.

@Mazuh
Last active February 23, 2025 06:49
Show Gist options
  • Save Mazuh/4b7a275ded38e2e031a5d40e28d1984d to your computer and use it in GitHub Desktop.
Save Mazuh/4b7a275ded38e2e031a5d40e28d1984d to your computer and use it in GitHub Desktop.

Revisions

  1. Mazuh revised this gist Nov 19, 2018. 3 changed files with 13 additions and 7 deletions.
    4 changes: 2 additions & 2 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ deployingDev:
    - aws configure set aws_secret_access_key "$DEV_AWS_SECRET"
    - ((aws s3api create-bucket --acl public-read --bucket my-app-dev && echo 'Created bucket.') || echo 'Already existing bucket.')
    - aws s3api put-bucket-website --bucket my-app-dev --website-configuration file://website.json
    - aws s3api put-bucket-policy --bucket my-app-dev --policy file://policy.json
    - aws s3api put-bucket-policy --bucket my-app-dev --policy file://policy-dev.json
    - aws s3 sync ./build/ s3://my-app-dev

    deployingProd:
    @@ -54,5 +54,5 @@ deployingProd:
    - aws configure set aws_secret_access_key "$PROD_AWS_SECRET"
    - ((aws s3api create-bucket --acl public-read --bucket my-app-prod && echo 'Created bucket.') || echo 'Already existing bucket.')
    - aws s3api put-bucket-website --bucket my-app-prod --website-configuration file://website.json
    - aws s3api put-bucket-policy --bucket my-app-prod --policy file://policy.json
    - aws s3api put-bucket-policy --bucket my-app-prod --policy file://policy-prod.json
    - aws s3 sync ./build/ s3://my-app-prod
    7 changes: 2 additions & 5 deletions policy.json → policy-dev.json
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,6 @@
    "Effect": "Allow",
    "Principal": "*",
    "Action": ["s3:GetObject"],
    "Resource": [
    "arn:aws:s3:::my-app-dev/*",
    "arn:aws:s3:::my-app-prod/*"
    ]
    "Resource": ["arn:aws:s3:::my-app-dev/*"]
    }
    }
    }
    9 changes: 9 additions & 0 deletions policy-prod.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    {
    "Statement": {
    "Sid": "PublicReadGetObject",
    "Effect": "Allow",
    "Principal": "*",
    "Action": ["s3:GetObject"],
    "Resource": ["arn:aws:s3:::my-app-prod/*"]
    }
    }
  2. Mazuh created this gist Nov 18, 2018.
    58 changes: 58 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    image: nikolaik/python-nodejs:latest

    stages:
    - install
    - test
    - deploy

    prodInstall:
    stage: install
    script:
    - npm install --production
    artifacts:
    untracked: true

    unitTesting:
    stage: test
    dependencies:
    - prodInstall
    script:
    - npm install
    - npm run build
    - npm test
    artifacts:
    untracked: true

    deployingDev:
    stage: deploy
    only:
    - dev
    dependencies:
    - prodInstall
    - unitTesting
    script:
    - pip3 install awscli
    - aws configure set profile bucket-dev
    - aws configure set aws_access_key_id "$DEV_AWS_KEY"
    - aws configure set aws_secret_access_key "$DEV_AWS_SECRET"
    - ((aws s3api create-bucket --acl public-read --bucket my-app-dev && echo 'Created bucket.') || echo 'Already existing bucket.')
    - aws s3api put-bucket-website --bucket my-app-dev --website-configuration file://website.json
    - aws s3api put-bucket-policy --bucket my-app-dev --policy file://policy.json
    - aws s3 sync ./build/ s3://my-app-dev

    deployingProd:
    stage: deploy
    only:
    - master
    dependencies:
    - prodInstall
    - unitTesting
    script:
    - pip3 install awscli
    - aws configure set profile bucket-prod
    - aws configure set aws_access_key_id "$PROD_AWS_KEY"
    - aws configure set aws_secret_access_key "$PROD_AWS_SECRET"
    - ((aws s3api create-bucket --acl public-read --bucket my-app-prod && echo 'Created bucket.') || echo 'Already existing bucket.')
    - aws s3api put-bucket-website --bucket my-app-prod --website-configuration file://website.json
    - aws s3api put-bucket-policy --bucket my-app-prod --policy file://policy.json
    - aws s3 sync ./build/ s3://my-app-prod
    12 changes: 12 additions & 0 deletions policy.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    {
    "Statement": {
    "Sid": "PublicReadGetObject",
    "Effect": "Allow",
    "Principal": "*",
    "Action": ["s3:GetObject"],
    "Resource": [
    "arn:aws:s3:::my-app-dev/*",
    "arn:aws:s3:::my-app-prod/*"
    ]
    }
    }
    5 changes: 5 additions & 0 deletions website.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    {
    "IndexDocument": {
    "Suffix": "index.html"
    }
    }