-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (125 loc) · 4.43 KB
/
entrypoint.yaml
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
# This is the main file of the github action workflow,
name: A Proxy Relay build
run-name: ${{ github.actor }} Opened ${{ github.ref }}
on:
# Trigger build(s) on specified branch, git action:
pull_request:
types: [opened, closed, synchronize]
branches:
- 'development'
- 'master'
jobs:
flake:
if: |
github.event_name == 'pull_request' &&
!github.ref_protected &&
!github.event.pull_request.merged &&
github.ref != 'development' &&
github.ref != 'staging' &&
github.ref != 'master' &&
github.ref != 'refs/heads/development' &&
github.ref != 'refs/heads/master' &&
github.event.action != 'closed'
uses: ./.github/workflows/test_python_flake.yaml
secrets: inherit
approve_development:
needs:
- flake
uses: ./.github/workflows/auto_approve.yaml
secrets: inherit
unittest:
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
github.ref == 'refs/heads/development' &&
github.event.action == 'closed'
uses: ./.github/workflows/test_python_tests.yaml
secrets: inherit
deployment_question:
needs:
- unittest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: string
uses: ASzc/change-string-case-action@v5
with:
string: ${{github.event.repository.name}}
- name: Create Pull Request
id: cpr
uses: actions/github-script@v6
with:
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: 'Deploy A Proxy Relay Package? - ${{ github.run_number }}',
owner,
repo,
head: '${{ github.ref_name }}',
base: 'master',
body: [
'Would you like to release a new build of aproxyrelay ?\n',
'Update A Proxy Relay to latest',
'---',
'Build and release new version!',
].join('\n'),
assignees: '@0x78f1935',
reviewers: '@0x78f1935',
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['docker', 'automated', 'prod-deployment'],
});
const os = require("os");
const fs = require("fs");
function setOutput(key, value) {
// Temporary hack until core actions library catches up with github new recommendations
const output = process.env['GITHUB_OUTPUT']
fs.appendFileSync(output, `${key}=${value}${os.EOL}`)
};
setOutput('pr_id', result.data.number);
deploy_package:
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'prod-deployment')
timeout-minutes: 30
runs-on: self-hosted
environment: production
permissions:
id-token: write
contents: write
pull-requests: write
repository-projects: write
steps:
- name: Check out the repo
uses: actions/checkout@v3
- id: string
uses: ASzc/change-string-case-action@v5
with:
string: ${{github.event.repository.name}}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Install dependencies
run: python3.11 -m pip install --upgrade pip setuptools wheel
- name: Build and Publish
run: |
python3.11 -m build
python3.11 -m twine upload --repository pypi dist/*
env:
CUSTOM_VERSION: 1.${{ github.run_number }}.${{ github.run_attempt }}.rc${{ github.run_id }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_RELEASE_TOKEN }}
- name: Create a Release
id: release
uses: ncipollo/release-action@v1
with:
artifacts: 'dist/aproxyrelay-*.tar.gz,dist/aproxyrelay-*.whl'
bodyFile: 'README.md'
generateReleaseNotes: true
makeLatest: true
token: ${{ secrets.PERSONAL_GITHUB_ACTIONS_TOKEN }}
tag: 1.${{ github.run_number }}.${{ github.run_attempt }}.rc${{ github.run_id }}+${{ steps.date.outputs.date }}