forked from 2i2c-org/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (79 loc) · 3.5 KB
/
recurrent-get-billing-data.yaml
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
name: "Recurrent: get billing data"
on:
workflow_dispatch:
schedule:
# Run on every 28th of the month at midnight
- cron: "0 0 28 * *"
jobs:
create_issue:
name: Create billing issues
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Get the next month name
id: get_next_month
run: |
echo "next_month=$(date -d '+1 month' +'%B')" >> $GITHUB_ENV
echo "start_date_as_iso=$(date -d '+1 month' +'%Y-%m-02')" >> $GITHUB_ENV
echo "end_date_as_iso=$(date -d '+1 month' +'%Y-%m-07')" >> $GITHUB_ENV
- name: Create issue for dedicated clusters billing
run: |
dedicated_issue=$(gh issue create \
--label "recurrent" \
--title "[Billing] Dedicated clusters: collect billing data for $NEXT_MONTH" \
--body "$BODY")
echo "dedicated_issue=$dedicated_issue" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.PROJECT_BOARD_PAT_TOKEN }}
GH_REPO: ${{ github.repository }}
NEXT_MONTH: ${{ env.next_month }}
BODY: |
### Context
- Dedicated clusters [instructions](https://infrastructure.2i2c.org/howto/bill/#communities-with-dedicated-cloud-accounts)
### Definition of Done
- [ ] Billing data is collected according to instructions.
- [ ] The billing slack was notified about the new billing data collected
- name: Create issue for shared clusters billing
run: |
shared_issue=$(gh issue create \
--label "recurrent" \
--title "[Billing] Shared clusters: collect billing data for $NEXT_MONTH" \
--body "$BODY")
echo "shared_issue=$shared_issue" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.PROJECT_BOARD_PAT_TOKEN }}
GH_REPO: ${{ github.repository }}
NEXT_MONTH: ${{ env.next_month }}
BODY: |
### Context
- Shared clusters [instructions](https://infrastructure.2i2c.org/howto/bill/#communities-in-shared-cloud-accounts) for performing this task
### Definition of Done
- [ ] Billing data is collected according to instructions.
- [ ] The billing slack was notified about the new billing data collected
- name: Sleep a bit to allow issues to be added to the board by automation
run: sleep 3
- name: "Dedicated clusters: set the relevant project board fields"
uses: EndBug/project-fields@v2
id: set-dedicated-fields
with:
operation: set
# If the fields name or type will change
# expect this step to fail
fields: Status,Estimate,Start date
github_token: ${{ secrets.PROJECT_BOARD_PAT_TOKEN }}
project_url: https://github.com/orgs/2i2c-org/projects/57
values: Up Next,1,${{ env.start_date_as_iso }}
resource_url: ${{ env.dedicated_issue }}
- name: "Shared clusters: set the relevant project board fields"
uses: EndBug/project-fields@v2
id: set-shared-fields
with:
operation: set
# If the fields name or type will change
# expect this step to fail
fields: Status,Estimate,Start date,End date
github_token: ${{ secrets.PROJECT_BOARD_PAT_TOKEN }}
project_url: https://github.com/orgs/2i2c-org/projects/57
values: Up Next,2,${{ env.start_date_as_iso }},${{ env.end_date_as_iso }}
resource_url: ${{ env.shared_issue }}