-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (48 loc) · 1.96 KB
/
cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# Sample workflow for building and deploying a Jekyll site to AWS S3
name: Cleanup site preview on AWS S3
on:
# Runs on pull requests against main branch
pull_request:
types:
- closed
branches:
- main
- jargon-pages
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-west-1'
jobs:
# Build job
cleanup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: "Delete batch to CloudSearch domain"
run: |
sed 's/$DATASET/${{ github.event.pull_request.number }}/g' batch-delete.json > batch-delete-updated.json
mv batch-delete-updated.json batch-delete.json
aws cloudsearchdomain upload-documents --endpoint-url http://doc-un-vocab-search-domain-bncds7z75oh72nto75ujlq4ib4.ap-southeast-2.cloudsearch.amazonaws.com --content-type application/json --documents batch-delete.json --region ap-southeast-2
- name: "Remove content from AWS S3"
run: aws s3 rm s3://uncefact-vocab-preview-sam-bucket-private/vocabulary/${{ github.event.pull_request.number }} --recursive
- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.TEST_DISTRIBUTION }}
PATHS: "/vocabulary/${{ github.event.pull_request.number }}/*"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
delete-branch:
runs-on: ubuntu-latest
steps:
- name: delete branch
uses: SvanBoxel/delete-merged-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}