generated from freckle/typescript-action-template
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (109 loc) · 3.06 KB
/
ci.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CI
on:
pull_request:
push:
branches: main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
S3_BUCKET: aws-s3-lock-ci
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'
- run: yarn install
- run: yarn build
- run: yarn test --passWithNoTests
integration:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
- id: lock-1
name: Acquire a lock
uses: ./
with:
bucket: ${{ env.S3_BUCKET }}
expires: 5s
- id: lock-2
name: Wait on previous lock then acquire our own
uses: ./
with:
bucket: ${{ env.S3_BUCKET }}
timeout: 10s
- name: Verify locks
run: |
[[ -n '${{ steps.lock-1.outputs.acquired-at }}' ]] # lock-1
[[ -n '${{ steps.lock-2.outputs.acquired-at }}' ]] # lock-2
# lock-2 acquired at should be +5s
integration-post:
needs: integration
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
- name: Assert lock was released
uses: ./
with:
bucket: ${{ env.S3_BUCKET }}
timeout: 0s
integration-separate:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
- id: lock-1
name: Acquire a lock
uses: ./acquire
with:
bucket: ${{ env.S3_BUCKET }}
expires: 5s
- id: lock-2
name: Wait on previous lock then acquire our own
uses: ./acquire
with:
bucket: ${{ env.S3_BUCKET }}
timeout: 10s
- name: Verify locks
run: |
[[ -n '${{ steps.lock-1.outputs.acquired-at }}' ]] # lock-1
[[ -n '${{ steps.lock-2.outputs.acquired-at }}' ]] # lock-2
# lock-2 acquired at should be +5s
- if: ${{ always() }}
name: Release lock-1
uses: ./release
with:
bucket: ${{ env.S3_BUCKET }}
key: ${{ steps.lock-1.outputs.key }}
- if: ${{ always() }}
name: Release lock-2
uses: ./release
with:
bucket: ${{ env.S3_BUCKET }}
key: ${{ steps.lock-2.outputs.key }}