-
Notifications
You must be signed in to change notification settings - Fork 5
74 lines (54 loc) · 1.97 KB
/
gcloud-filestore.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
# more details this workflow and other at https://github.com/didier-durand/gcloud-tests
name: Use GCP filestore
on:
workflow_dispatch:
inputs:
push:
#protection to avoid triggering when other workflow is modified
paths:
- '!.github/workflows/**'
- '.github/workflows/gcloud-filestore.yml'
schedule:
- cron: '0 4 30 * MON'
env:
GCP_VERBOSITY: warning
GCP_BUCKET: gs://test-gcp-bucket
jobs:
use-GCP-filestore-services:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Get gcloud version & info
run: |-
echo '--- gcloud version ---'
gcloud version
echo '--- gcloud info ---'
gcloud info --anonymize
# https://cloud.google.com/storage/docs/creating-buckets
- name: Create bucket
run: |-
gsutil mb -p ${{ secrets.GCP_PROJECT }} "$GCP_BUCKET-$GITHUB_SHA"
- name: Copy file to bucket
run: |-
echo "content: $GITHUB_SHA" > "/tmp/file-$GITHUB_SHA.txt"
gsutil cp "/tmp/file-$GITHUB_SHA.txt" "$GCP_BUCKET-$GITHUB_SHA"
- name: List bucket content
run: |-
gsutil ls -r "$GCP_BUCKET-$GITHUB_SHA/**"
# diff is used to make sure that read content equals original one
- name: Read file from bucket (and diff to validate)
run: |-
gsutil cp "$GCP_BUCKET-$GITHUB_SHA/file-$GITHUB_SHA.txt" "/tmp/file-$GITHUB_SHA-read.txt"
diff "/tmp/file-$GITHUB_SHA.txt" "/tmp/file-$GITHUB_SHA-read.txt"
- name: Delete bucket
run: |-
gsutil rm -r "$GCP_BUCKET-$GITHUB_SHA"
- name: List filestore buckets (to see if deleted)
run: |-
gsutil ls -p ${{ secrets.GCP_PROJECT }}