forked from apache/cloudstack-kubernetes-provider
-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (79 loc) · 2.88 KB
/
release.yaml
File metadata and controls
94 lines (79 loc) · 2.88 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
name: Release and Image Push
on:
push:
branches:
- develop
- main
tags:
- v*
env:
REGISTRY_NAME: ghcr.io/leaseweb
IMAGE_NAME: "cloudstack-kubernetes-provider"
jobs:
build-and-push:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_NAME }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image (Develop Branch)
if: github.ref == 'refs/heads/develop'
run: |
docker build . -t ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:develop
docker push ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:develop
- name: Build and Push Docker Image (Main Branch)
if: github.ref == 'refs/heads/main'
run: |
docker build . -t ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:main
docker push ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:main
- name: Build and Push Docker Image (Tags)
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
docker build . -t ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:${VERSION}
docker push ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:${VERSION}
release:
name: Release
runs-on: ubuntu-22.04
# Run only if previous job has succeeded
needs: [build-and-push]
# Create a release only for tags v*
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Create manifest
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
echo "---" >> manifest.yaml
cat deploy/k8s/rbac.yaml >> manifest.yaml
echo "---" >> manifest.yaml
sed -E "s|image: +cloudstack-kubernetes-provider|image: ${REGISTRY_NAME}/${IMAGE_NAME}:${VERSION}|" deploy/k8s/deployment.yaml >> manifest.yaml
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: manifest.yaml
asset_name: manifest.yaml
asset_content_type: application/x-yaml