-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (114 loc) · 4.5 KB
/
test.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
125
126
127
128
129
130
131
132
133
134
135
# This workflow tests the `octue/get-deployment-info` GitHub action.
name: test-deployment-info
on:
pull_request:
jobs:
get-package-version:
if: "!contains(github.event.head_commit.message, 'skipci')"
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
outputs:
version: ${{ steps.get-package-version.outputs.version }}
version_slug: ${{ steps.get-package-version.outputs.version_slug }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Install poetry
uses: snok/install-poetry@v1.3.3
- name: Get package version
id: get-package-version
run: |
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
echo "version_slug=$(poetry version -s | tr . -)" >> $GITHUB_OUTPUT
docker:
runs-on: ubuntu-latest
needs: get-package-version
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5.1.0
with:
context: .
push: true
tags: octue/get-deployment-info:${{ needs.get-package-version.outputs.version }}
test-action:
runs-on: ubuntu-latest
needs: [get-package-version, docker]
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Get deployment info
id: get-deployment-info
uses: ./
with:
gcp_project_name: my-test-project
gcp_project_number: 1234
gcp_region: europe-west6
gcp_resource_affix: my-affix
gcp_service_name: my-test-service
- name: Get short SHA
id: get-short-sha
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Check `branch_tag_kebab`
uses: nick-fields/assert-action@v1
with:
expected: refs-pull-${{ github.event.number }}-merge
actual: ${{ steps.get-deployment-info.outputs.branch_tag_kebab }}
- name: Check `image_latest_artifact`
uses: nick-fields/assert-action@v1
with:
expected: europe-west6-docker.pkg.dev/my-test-project/my-affix/my-test-service:refs-pull-${{ github.event.number }}-mer-latest
actual: ${{ steps.get-deployment-info.outputs.image_latest_artifact }}
- name: Check `image_latest_tag`
uses: nick-fields/assert-action@v1
with:
expected: refs-pull-${{ github.event.number }}-mer-latest
actual: ${{ steps.get-deployment-info.outputs.image_latest_tag }}
- name: Check `image_version_artifact`
uses: nick-fields/assert-action@v1
with:
expected: europe-west6-docker.pkg.dev/my-test-project/my-affix/my-test-service:refs-pull-${{ github.event.number }}-mer
actual: ${{ steps.get-deployment-info.outputs.image_version_artifact }}
- name: Check `image_version_tag`
uses: nick-fields/assert-action@v1
with:
expected: refs-pull-${{ github.event.number }}-mer
actual: ${{ steps.get-deployment-info.outputs.image_version_tag }}
- name: Check `short_sha`
uses: nick-fields/assert-action@v1
with:
expected: ${{ steps.get-short-sha.outputs.SHORT_SHA }}
actual: ${{ steps.get-deployment-info.outputs.short_sha }}
- name: Check `version`
uses: nick-fields/assert-action@v1
with:
expected: ${{ needs.get-package-version.outputs.version }}
actual: ${{ steps.get-deployment-info.outputs.version }}
- name: Check `version_slug`
uses: nick-fields/assert-action@v1
with:
expected: ${{ needs.get-package-version.outputs.version_slug }}
actual: ${{ steps.get-deployment-info.outputs.version_slug }}
- name: Check `revision_tag`
uses: nick-fields/assert-action@v1
with:
expected: refs-pull-${{ github.event.number }}-mer
actual: ${{ steps.get-deployment-info.outputs.revision_tag }}
- name: Check `revision_tag_slug`
uses: nick-fields/assert-action@v1
with:
expected: refs-pull-${{ github.event.number }}-mer
actual: ${{ steps.get-deployment-info.outputs.revision_tag_slug }}