Skip to content

Commit 3a5d5f4

Browse files
Kyle KeatingLMS007
authored andcommitted
Improve gh actions
Publish now required a specific commit message. This allows lambdas to be uploaded in rapid production without publishing a new version
1 parent d6fcd19 commit 3a5d5f4

File tree

2 files changed

+54
-60
lines changed

2 files changed

+54
-60
lines changed
Lines changed: 53 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release and publishing version specific packages
1+
name: Release package and upload zip to lambdas in production
22

33
on:
44
push:
@@ -7,6 +7,7 @@ on:
77

88
jobs:
99
node-run-tests:
10+
name: Run tests and create zip artifact
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@v2
@@ -17,8 +18,56 @@ jobs:
1718
- run: yarn jest
1819
- run: yarn check-format
1920
- run: yarn lint
21+
# Build lambda zip
22+
- uses: ./.github/actions/build-zip
23+
with:
24+
ACTIONS_ACCESS_KEY: ${{ secrets.ACTIONS_ACCESS_KEY }}
25+
26+
lambda-upload-zip-to-aws:
27+
needs: [node-run-tests]
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
region: [
32+
us-east-1,
33+
us-west-2,
34+
ap-east-1,
35+
ap-south-1,
36+
ap-southeast-1,
37+
ap-northeast-1,
38+
eu-central-1,
39+
eu-west-3,
40+
sa-east-1
41+
]
42+
location_key: [
43+
AWS-US-EAST-1,
44+
AWS-US-WEST-2,
45+
AWS-AP-EAST-1,
46+
AWS-AP-SOUTH-1,
47+
AWS-AP-SOUTHEAST-1,
48+
AWS-AP-NORTHEAST-1,
49+
AWS-EU-CENTRAL-1,
50+
AWS-EU-WEST-3,
51+
AWS-SA-EAST-1
52+
]
53+
steps:
54+
- uses: actions/checkout@v2
55+
- uses: ./.github/actions/upload-lambda
56+
with:
57+
ACTIONS_ACCESS_KEY: ${{ secrets.ACTIONS_ACCESS_KEY }}
58+
worker_env: >
59+
BASE_URL=https://rapidapi.com/testing,
60+
LOCATION_CONTEXT=Default,
61+
LOCATION_KEY=${{ matrix.location_key }},
62+
LOCATION_SECRET=${{ secrets.LOCATION_SECRET_PROD_DEFAULT }},
63+
WORKER_LOGGING=off
64+
aws_access_key_id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }}
65+
aws_secret_access_key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }}
66+
aws_region: ${{ matrix.region }}
67+
function_name: rapidapi-prod-testing-worker
2068

2169
npm-publish-package:
70+
if: "contains(github.event.head_commit.message, 'ci-publish-package')"
2271
needs: [node-run-tests]
2372
runs-on: ubuntu-latest
2473
steps:
@@ -36,6 +85,7 @@ jobs:
3685
registry: https://npm.pkg.github.com
3786

3887
make-release:
88+
if: "contains(github.event.head_commit.message, 'ci-publish-package')"
3989
needs: [npm-publish-package]
4090
runs-on: ubuntu-latest
4191
steps:
@@ -58,38 +108,8 @@ jobs:
58108
draft: false
59109
prerelease: false
60110

61-
lambda-build-worker-zip:
62-
needs: [node-run-tests]
63-
runs-on: ubuntu-latest
64-
steps:
65-
- uses: actions/checkout@v2
66-
- name: Use Node.js
67-
uses: actions/setup-node@v2
68-
with:
69-
always-auth: true
70-
node-version: v14.15.4
71-
registry-url: https://registry.npmjs.org
72-
scope: "@rapidapi"
73-
74-
- name: Prepare worker_dist directory
75-
run: |
76-
cp -R ./ ../dist
77-
- name: Install node packages
78-
run: cd ../dist && yarn install --frozen-lockfile
79-
env:
80-
NODE_AUTH_TOKEN: ${{secrets.ACTIONS_ACCESS_KEY}}
81-
# Kind of a hack to avoid recursively copying the dist folder
82-
- name: Move dist folder down
83-
run: mv ../dist dist
84-
- name: Zip dist
85-
run: zip -rq worker.zip dist/*
86-
- name: Upload the zipped worker
87-
uses: actions/upload-artifact@v2
88-
with:
89-
name: zipped_worker
90-
path: worker.zip
91-
92111
docker-build-push-worker:
112+
if: "contains(github.event.head_commit.message, 'ci-publish-package')"
93113
needs: [node-run-tests]
94114
runs-on: ubuntu-latest
95115
steps:
@@ -107,30 +127,4 @@ jobs:
107127
file: ./docker/Dockerfile.worker
108128
push: true
109129
tags: rapidapicloud/testing-worker:latest
110-
####################################################################################
111-
############################## DEPLOY TO REGIONS ###################################
112-
####################################################################################
113-
lambda-upload-zip-to-aws:
114-
strategy:
115-
matrix:
116-
region: [us-east-1, us-west-2, ap-south-1, ap-southeast-1, ap-northeast-1, eu-central-1, eu-west-3, sa-east-1]
117-
runs-on: ubuntu-latest
118-
needs:
119-
- lambda-build-worker-zip
120-
steps:
121-
- name: Download the zipped worker
122-
uses: actions/download-artifact@v2
123-
with:
124-
name: zipped_worker
125-
####################################################################################
126-
- name: Deploy worker to production => (${{ matrix.regions }})
127-
uses: appleboy/lambda-action@v0.1.5
128-
with:
129-
aws_access_key_id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }}
130-
aws_secret_access_key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }}
131-
aws_region: ${{ matrix.region }}
132-
function_name: rapidapi-prod-testing-worker
133-
zip_file: worker.zip
134-
handler: dist/src/main.execute
135-
description: "aws:states:opt-out"
136-
130+

.github/workflows/staging-change.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release and publishing version specific packages
1+
name: Upload zip to lambdas in staging
22

33
on:
44
push:

0 commit comments

Comments
 (0)