Skip to content

Commit 0a46bbc

Browse files
committed
use GitHub Actions
1 parent 392b9b1 commit 0a46bbc

10 files changed

+62
-283
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: New Application Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
required: true
8+
app_repo:
9+
required: true
10+
image:
11+
required: true
12+
13+
14+
jobs:
15+
update-image-tag:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Wrap Input
20+
run: |
21+
echo "::set-env name=APP_REPO::${{ github.event.inputs.app_repo }}"
22+
echo "::set-env name=TAG_NAME::${{ github.event.inputs.tag_name }}"
23+
echo "::set-env name=IMAGE::${{ github.event.inputs.image }}"
24+
echo "::set-env name=DEPLOY_FILE_PATH::${{ github.event.inputs.app_repo }}/deployment.yaml"
25+
- uses: actions/checkout@v2
26+
- uses: azure/setup-kubectl@v1
27+
id: install
28+
- name: patch deployment manifest
29+
run: kubectl patch --filename=${{ env.DEPLOY_FILE_PATH }} --patch='{"spec":{"template":{"spec":{"containers":[{"name":"${{ env.APP_REPO }}","image":"${{ env.IMAGE }}"}]}}}}' --local=true -o yaml > tmp.yaml
30+
- name: commit change
31+
run: |
32+
git config user.name ${{ github.actor }}
33+
git config user.email '${{ github.actor }}@users.noreply.github.com'
34+
rm -f ${{ env.DEPLOY_FILE_PATH }}
35+
mv tmp.yaml ${{ env.DEPLOY_FILE_PATH }}
36+
git add ${{ env.DEPLOY_FILE_PATH }}
37+
git diff-index --quiet HEAD || git commit -m "Set ${{ env.APP_REPO }} to version ${{ env.TAG_NAME }}"
38+
- name: Create Pull Request
39+
uses: peter-evans/create-pull-request@v3
40+
with:
41+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
42+
commit-message: Update report
43+
committer: GitHub <[email protected]>
44+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
45+
signoff: false
46+
branch: new_release_${{ env.APP_REPO }}-${{ env.TAG_NAME }}
47+
title: 'Set ${{ env.APP_REPO }} to version ${{ env.TAG_NAME }}'
48+
body: |
49+
This PR was automatically created.
50+
Please review and merge to deploy.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Example Environment Repository
2+
This is a environment repository to perform *Operations on Pull Request*.
3+
It runs a GitHub Workflow to update Kubernetes Deployment Manifests via pull requests.
4+
5+
## Requirements
6+
7+
- Secret: `PERSONAL_ACCESS_TOKEN` to modify repositories and create pull requests.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
---
2-
apiVersion: extensions/v1beta1
1+
apiVersion: apps/v1
32
kind: Deployment
43
metadata:
54
name: example-application
6-
annotations:
7-
fluxcd.io/automated: 'true'
85
spec:
9-
replicas: 3
6+
replicas: 1
107
template:
118
metadata:
129
labels:
1310
app: example-application
1411
spec:
1512
containers:
1613
- name: example-application
17-
image: gcr.io/gitops-255005/example-application:master-5ebae72
14+
image: <image-name>:<tag>
1815
ports:
1916
- containerPort: 8080
17+

cluster/example-service.yaml example-application/service.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
app: example-application
77
spec:
8-
type: LoadBalancer
8+
type: ClusterIP
99
ports:
1010
- port: 8080
1111
selector:

flux/flux-account.yaml

-38
This file was deleted.

flux/flux-deployment.yaml

-180
This file was deleted.

flux/flux-ns.yaml

-5
This file was deleted.

flux/flux-secret.yaml

-7
This file was deleted.

flux/memcache-dep.yaml

-34
This file was deleted.

flux/memcache-svc.yaml

-12
This file was deleted.

0 commit comments

Comments
 (0)