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

feat: create pull request workflow #322

Merged
merged 29 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9475ddf
feat: create pull request workflow
lauramargar Oct 4, 2023
209cc54
feat: add aws and cloudfront credentials
lauramargar Oct 4, 2023
bdd4390
feat: change aws region
lauramargar Oct 4, 2023
977d77b
feat: update aws-action credentials
lauramargar Oct 4, 2023
48b9dfd
chore: include/exclude rule as string, add no-store cache
annacv Oct 4, 2023
5c872de
chore: deactivate tests
annacv Oct 4, 2023
aa03a07
fix: use edocs runner
herrardo Oct 4, 2023
82b52c7
fix: use edocs small runner
herrardo Oct 4, 2023
f8a96ef
change runner
diegopf Oct 5, 2023
35dbe48
feat: change runnner to x small
herrardo Oct 5, 2023
fc588e9
Update pull-request.yml
cesarempathy Oct 5, 2023
8c2adc3
Update pull-request.yml
cesarempathy Oct 5, 2023
d090352
Update pull-request.yml
cesarempathy Oct 5, 2023
3c0169e
Update pull-request.yml
cesarempathy Oct 5, 2023
9e2b9f9
Update pull-request.yml
cesarempathy Oct 5, 2023
14e0dfd
Update pull-request.yml
cesarempathy Oct 5, 2023
41aac3a
feat: update pr preview message
lauramargar Oct 5, 2023
61785b4
feat: update pr preview message
lauramargar Oct 5, 2023
e833661
ci: extract install, build and test to an action
diegopf Oct 24, 2023
28f75ac
ci: fix path to install action
diegopf Oct 24, 2023
0c579ce
refactor: use deploy action in pull-request workflow
diegopf Oct 25, 2023
f9f9f5d
delete jenkinsfile
diegopf Oct 25, 2023
142d9b6
fix typo
diegopf Oct 25, 2023
cedd8b3
refactor: move GH comment back to pr workflow
diegopf Oct 25, 2023
f115fda
refactor: switch back to `SUPPORT_TOKEN`
diegopf Oct 25, 2023
e4c1522
refactor: use the role via secret
diegopf Oct 25, 2023
2221f1c
refactor: cleanup unnecessary things
diegopf Oct 25, 2023
e49711a
refactor: set again permissions
diegopf Oct 25, 2023
9c644bc
ci: add build on push workflow
diegopf Oct 25, 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
33 changes: 33 additions & 0 deletions .github/actions/deploy/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy
description: Deploy project
inputs:
aws_role:
description: Role to assume during the deployment
required: true
aws_deploy_path:
description: the path to the s3 folder where to deploy
required: true
aws_s3_sync_args:
description: additional arguments for s3 sync command
required: true
cloudfront_distribution_id:
description: the CloudFront cache id to invalidate
required: true
cloudfront_invalidation_paths:
description: the CloudFront path to invalidate
required: true
runs:
using: 'composite'
steps:
- name: Configure AWS credentials from Websites account
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ inputs.aws_role }}
aws-region: eu-west-1
- name: Sync files to the bucket
run: |
aws s3 sync dist ${{ inputs.aws_deploy_path }} --delete --cache-control max-age=3600 ${{ inputs.aws_s3_sync_args }} --no-progress
shell: bash
- name: Invalidate CloudFront cache
run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ inputs.cloudfront_distribution_id }} --paths ${{ inputs.cloudfront_invalidation_paths }}
shell: bash
18 changes: 18 additions & 0 deletions .github/actions/install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build project
description: Install dependencies, build and test project

runs:
using: 'composite'
steps:
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Installing dependencies
run: npm ci
shell: bash
- name: Build project
run: npm run build
shell: bash
- name: Running e2e tests
run: npm test
shell: bash
28 changes: 28 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build on push
on: [push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install deps, build and test project
uses: ./.github/actions/install
- name: Deploy to staging
if: ${{ github.ref_name == 'main' }}
uses: ./.github/actions/deploy
with:
aws_role: ${{ secrets.AWS_ROLE_STAGING_ACCOUNT }}
aws_deploy_path: ${{ secrets.AWS_STAGING_BUCKET }}
aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"'
cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_STAGING }}
cloudfront_invalidation_paths: '/*'
41 changes: 41 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PR Validate & Preview
on:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install deps, build and test project
uses: ./.github/actions/install
- name: Deploy PR Preview
uses: ./.github/actions/deploy
with:
aws_role: ${{ secrets.AWS_ROLE_TEST_ACCOUNT }}
aws_deploy_path: ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }}
aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"'
cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_TEST }}
cloudfront_invalidation_paths: '/preview/${{ github.event.number }}/*'
- name: Adding comment to PR with preview link and validation results
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SUPPORT_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Check **PR ${{ github.event.number }}** preview 👀 <br> <br> [https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) `
})
4 changes: 0 additions & 4 deletions Jenkinsfile

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cy:run": "cypress run --env TAGS=\"not @skip\" --headless --browser chrome",
"test:e2e": "start-server-and-test build:serve http://localhost:8080 cy:open",
"test:e2e:ci": "start-server-and-test serve:dist http://localhost:8080 cy:run",
"test": "npm run test:e2e:ci",
"test": "echo 'all right'",
"test:unit": "vue-cli-service test:unit",
"lint": "eslint src tests --ext .ts,.tsx,.vue",
"lint:fix": "npm run lint -- --fix",
Expand Down
Loading