File tree Expand file tree Collapse file tree 6 files changed +124
-17
lines changed Expand file tree Collapse file tree 6 files changed +124
-17
lines changed Original file line number Diff line number Diff line change 77 branches :
88 - feat/github-actions
99
10+ concurrency :
11+ group : deploy-prod-stack
12+
1013jobs :
1114 auto-update :
1215 runs-on : ubuntu-latest
13-
16+ env :
17+ AWS_REGION : ap-northeast-1
1418 steps :
1519 - name : Checkout
1620 uses : actions/checkout@v3
1721 with :
1822 fetch-depth : 0
23+ - uses : aws-actions/configure-aws-credentials@v4
24+ with :
25+ aws-region : ${{ env.AWS_REGION }}
26+ role-to-assume : ${{ secrets.AWS_ROLE_ARN }}
1927 - name : Install serverless
2028 run : npm install -g serverless
2129 - name : Note docker image digest
4452 SHA256_DIGEST=${{ steps.docker-image-digest.outputs.SHA256_DIGEST }}
4553 CHROME_VERSION=${{ steps.chrome-versions.outputs.CHROME_VERSION }}
4654 SELENIUM_VERSION=${{ steps.selenium-version.outputs.SELENIUM_VERSION }}
47- sed -r "s/public.ecr.aws\/lambda\/python[:@a-z0-9]+/public.ecr.aws\/lambda\/python\@sha256\:${SHA256_DIGEST}/g; s/chrome-for-testing\/[0-9.]+/chrome-for-testing\/${CHROME_VERSION}/g; s/selenium==[0-9\.]*/selenium==${SELENIUM_VERSION}/g" -i Dockerfile
55+ sed -r "s/public.ecr.aws\/lambda\/python[:@a-z0-9]+/public.ecr.aws\/lambda\/python\@sha256\:${SHA256_DIGEST}/g; s/chrome-for-testing-public \/[0-9.]+/chrome-for-testing-public \/${CHROME_VERSION}/g; s/selenium==[0-9\.]*/selenium==${SELENIUM_VERSION}/g" -i Dockerfile
4856 - name : Deploy
4957 run : sls deploy
50- env :
51- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
52- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
53- AWS_REGION : ${{ secrets.AWS_REGION }}
5458 - name : Note chrome version
5559 id : chrome-version
5660 run : |
6468 - name : Invoke
6569 id : invoke
6670 run : sls invoke -f demo > /tmp/scraping-result.txt
67- env :
68- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
69- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
70- AWS_REGION : ${{ secrets.AWS_REGION }}
7171 - name : Archive result
7272 uses : actions/upload-artifact@v3
7373 if : ${{ !env.ACT }}
Original file line number Diff line number Diff line change 1+ name : check
2+
3+ on :
4+ - push
5+
6+ permissions :
7+ id-token : write
8+ contents : read
9+
10+ concurrency :
11+ group : deploy-prod-stack
12+
13+ jobs :
14+ check :
15+ runs-on : ubuntu-latest
16+ env :
17+ AWS_REGION : ap-northeast-1
18+ steps :
19+ - uses : actions/checkout@v4
20+ - uses : aws-actions/configure-aws-credentials@v4
21+ with :
22+ aws-region : ${{ env.AWS_REGION }}
23+ role-to-assume : ${{ secrets.AWS_ROLE_ARN }}
24+ - name : Install Serverless Framework
25+ run : npm install -g serverless
26+ - name : Wait for CloudFormation stack to be updated
27+ run : aws cloudformation wait stack-update-complete --stack-name="docker-selenium-lambda-prod" || true
28+ - name : Deploy
29+ run : sls deploy
30+ - name : Invoke
31+ run : sls invoke --function demo |& tee /tmp/scraping-result.txt
32+ - name : Check
33+ run : cat /tmp/scraping-result.txt | grep -q "This domain is for use in illustrative examples in documents"
Original file line number Diff line number Diff line change 88 branches :
99 - feat/github-actions**
1010
11+ concurrency :
12+ group : deploy-prod-stack
13+
1114jobs :
1215 demo-test :
1316 runs-on : ubuntu-latest
14-
17+ env :
18+ AWS_REGION : ap-northeast-1
1519 steps :
20+ - uses : aws-actions/configure-aws-credentials@v4
21+ with :
22+ aws-region : ${{ env.AWS_REGION }}
23+ role-to-assume : ${{ secrets.AWS_ROLE_ARN }}
1624 - name : Demo README's instructions
1725 run : |
1826 npm install -g serverless
1927 sls create --template-url "https://github.com/umihico/docker-selenium-lambda/tree/main" --path docker-selenium-lambda && cd $_
2028 sls deploy
2129 sls invoke --function demo |& tee /tmp/scraping-result.txt
2230 cat /tmp/scraping-result.txt | grep -q "This domain is for use in illustrative examples in documents"
23- env :
24- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
25- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26- AWS_REGION : ${{ secrets.AWS_REGION }}
Original file line number Diff line number Diff line change 1+ terraform {
2+ backend "local" {
3+ path = " .terraform/oidc/terraform.tfstate"
4+ }
5+ }
6+
7+ provider "aws" {
8+ region = " ap-northeast-1"
9+ }
10+
11+ data "aws_caller_identity" "current" {}
12+
13+ data "aws_iam_openid_connect_provider" "github_actions" {
14+ arn = " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :oidc-provider/token.actions.githubusercontent.com"
15+ }
16+
17+ resource "aws_iam_role" "github_actions" {
18+ name = " github-actions-docker-selenium-lambda"
19+ assume_role_policy = jsonencode ({
20+ Version = " 2012-10-17"
21+ Statement = [{
22+ Effect = " Allow"
23+ Action = " sts:AssumeRoleWithWebIdentity"
24+ Principal = {
25+ Federated = data.aws_iam_openid_connect_provider.github_actions.arn
26+ }
27+ Condition = {
28+ StringLike = {
29+ " token.actions.githubusercontent.com:sub" = [
30+ " repo:umihico/docker-selenium-lambda:*"
31+ ]
32+ }
33+ }
34+ }]
35+ })
36+ managed_policy_arns = [" arn:aws:iam::aws:policy/AdministratorAccess" ]
37+ }
38+
39+ output "aws_iam_openid_connect_provider" {
40+ value = data. aws_iam_openid_connect_provider . github_actions . arn
41+ }
42+
43+ output "aws_iam_role" {
44+ # gh secret set AWS_ROLE_ARN
45+ value = aws_iam_role. github_actions . arn
46+ }
Original file line number Diff line number Diff line change 11FROM public.ecr.aws/lambda/python@sha256:c95e0a2af8bd2bb58e9de147305d30a6e8e598200ef4a2e9a06d14a4934fb204 as build
22RUN dnf install -y unzip && \
3- curl -Lo "/tmp/chromedriver-linux64.zip" "https://edgedl.me.gvt1. com/edgedl/ chrome/chrome -for-testing/121.0.6167.85/linux64/chromedriver-linux64.zip" && \
4- curl -Lo "/tmp/chrome-linux64.zip" "https://edgedl.me.gvt1. com/edgedl/ chrome/chrome -for-testing/121.0.6167.85/linux64/chrome-linux64.zip" && \
3+ curl -Lo "/tmp/chromedriver-linux64.zip" "https://storage.googleapis. com/chrome-for-testing-public /121.0.6167.85/linux64/chromedriver-linux64.zip" && \
4+ curl -Lo "/tmp/chrome-linux64.zip" "https://storage.googleapis. com/chrome-for-testing-public /121.0.6167.85/linux64/chrome-linux64.zip" && \
55 unzip /tmp/chromedriver-linux64.zip -d /opt/ && \
66 unzip /tmp/chrome-linux64.zip -d /opt/
77
You can’t perform that action at this time.
0 commit comments