-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (98 loc) · 3.52 KB
/
pr-2-code-engine.yml
File metadata and controls
116 lines (98 loc) · 3.52 KB
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
# Copyright © 2022 Dimitri Prosper <dimitri.prosper@gmail.com>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Create/Delete/Update a project in IBM Cloud Code Engine on PR
on:
pull_request:
branches: [main]
types: [opened, closed]
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'docs/**'
env:
REGISTRY_REPOSITORY: ${{ github.repository }}
REGION: us-east
RESOURCE_GROUP: default
CE_REGISTRY_SECRET: registry-secret
REGISTRY: ghcr.io
jobs:
build_publish_deploy:
if: github.event.action == 'opened'
name: Create
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1.10.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v2.8.0
with:
context: ./
file: ./api/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/${{ env.REGISTRY_REPOSITORY }}:${{ github.event.pull_request.head.sha }}
labels: ${{ steps.meta.outputs.labels }}
- name: Setup the IBM Cloud CLI and Login
uses: dprosper/ic-setup-cli@v0.1.2
with:
API_KEY: ${{ secrets.API_KEY }}
INSTALL_PLUGINS: code-engine
REGION: ${{ env.REGION }}
RESOURCE_GROUP: ${{ env.RESOURCE_GROUP }}
- name: Deploy to IBM Cloud Code Engine
uses: dprosper/icce-cud-cli@v0.4.2
with:
IMAGE: ${{ env.REGISTRY}}/${{ env.REGISTRY_REPOSITORY }}:${{ github.event.pull_request.head.sha }}
CE_ACTION: create
CE_PROJECT_NAME: project-${{ github.event.pull_request.head.sha }}
CE_APP_NAME: app-${{ github.event.pull_request.head.sha }}
REGISTRY: ${{ env.REGISTRY }}
APP_PORT: 3001
APP_SECRET: ${{ secrets.APP_SECRET }}
delete:
if: github.event.action == 'closed'
name: Delete
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Setup the IBM Cloud CLI and Login
uses: dprosper/ic-setup-cli@v0.1.2
with:
API_KEY: ${{ secrets.API_KEY }}
INSTALL_PLUGINS: code-engine
REGION: ${{ env.REGION }}
RESOURCE_GROUP: ${{ env.RESOURCE_GROUP }}
- name: Delete from IBM Cloud Code Engine
uses: dprosper/icce-cud-cli@v0.4.2
with:
ISSUE_NUMBER: ${{ github.event.pull_request.number }}
CE_PROJECT_NAME: project-${{ github.event.pull_request.head.sha }}
CE_ACTION: delete