-
Notifications
You must be signed in to change notification settings - Fork 169
85 lines (75 loc) · 3.53 KB
/
create-deploy-resources.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
name: Create deploy resources
env:
IMAGE_BASE_NAME: "quay.io/quarkus-super-heroes"
on:
workflow_call:
inputs:
commit_id:
description: The commit id of the original commit which triggered the workflow
required: true
type: string
branch:
description: The target branch of the commit id
required: true
type: string
workflow_dispatch:
jobs:
create-deploy-resources:
if: (github.repository == 'quarkusio/quarkus-super-heroes') && (contains(fromJSON('["workflow_dispatch", "schedule"]'), github.event_name) || ((github.event_name == 'worflow_run') && ((github.event.workflow_run.event == 'push') || (github.event.workflow_run.event == 'workflow_dispatch') && (github.event.workflow_run.conclusion == 'success') && ((inputs.branch == 'main') || (inputs.branch == 'rhbq-2.7') || (inputs.branch == 'rhbq-2.13') || (inputs.branch == '2.13.Final') || (inputs.branch == '3.2.Final') || (inputs.branch == 'rhbq-3.2') || (inputs.branch == '3.8.Final') || (inputs.branch == 'rhbq-3.8')))))
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
pull-requests: write
steps:
- name: Calculate Branch (NOT workflow_dispatch event)
if: github.event_name != 'workflow_dispatch'
run: |
echo "REF=${{ inputs.commit_id }}" >> $GITHUB_ENV
echo "BRANCH=${{ inputs.branch }}" >> $GITHUB_ENV
- name: Calculate Branch (workflow_dispatch event)
if: github.event_name == 'workflow_dispatch'
run: |
echo "REF=${{ github.sha }}" >> $GITHUB_ENV
echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Checkout from ${{ env.REF }}
uses: actions/checkout@v4
with:
ref: ${{ env.REF }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: maven
- name: Create k8s resources
shell: bash
run: scripts/generate-k8s-resources.sh
- name: Create docker-compose resources
shell: bash
run: scripts/generate-docker-compose-resources.sh
- name: Commit generated resources via PR
id: create-pr
uses: peter-evans/create-pull-request@v7
with:
add-paths: |
**/deploy/k8s/*.yml
deploy/k8s/*.yml
**/deploy/docker-compose/*.yml
deploy/docker-compose/*.yml
deploy/db-init/**
commit-message: "Generate deploy resources (from ${{ github.workflow }} run # ${{ github.run_number }})"
branch: create-deploy-resources/sourceref
branch-suffix: short-commit-hash
delete-branch: true
base: ${{ env.BRANCH }}
title: "Generate deploy resources (from ${{ github.workflow }} run # ${{ github.run_number }})"
body: "Generated deployment resource changes from [${{ github.workflow }} run # ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}), which was triggered by commit ${{ env.REF }}."
labels: |
Generated Resources
- name: Merge PR
if: (steps.create-pr.outputs.pull-request-operation == 'created') && (steps.create-pr.outputs.pull-request-number)
run: |
echo "${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}" | gh auth login --with-token
gh pr review --approve ${{ steps.create-pr.outputs.pull-request-number }}
gh pr merge --squash --admin ${{ steps.create-pr.outputs.pull-request-number }}