fix: release actions using repository dispatch [ci skip]
This commit is contained in:
parent
de8b885140
commit
84e67638d4
2 changed files with 53 additions and 42 deletions
45
.github/workflows/docker_build_push.yml
vendored
45
.github/workflows/docker_build_push.yml
vendored
|
|
@ -1,11 +1,12 @@
|
|||
name: Build and publish docker
|
||||
name: Build and publish docker, and trigger release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "develop"
|
||||
- "main"
|
||||
pull_request:
|
||||
types: [synchronize, opened]
|
||||
types: [closed]
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
GHCR: ghcr.io
|
||||
|
|
@ -15,6 +16,7 @@ env:
|
|||
jobs:
|
||||
build_and_push:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
@ -119,19 +121,19 @@ jobs:
|
|||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Nightly build test on amd64 for pull requests
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
build-args: ${{ matrix.build-args }}
|
||||
push: false
|
||||
build-contexts: ${{ matrix.build-contexts }}
|
||||
file: ${{ matrix.dockerfile }}
|
||||
cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }}
|
||||
cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }}
|
||||
platforms: linux/amd64
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
# - name: Nightly build test on amd64 for pull requests
|
||||
# if: ${{ github.event_name == 'pull_request' }}
|
||||
# uses: docker/build-push-action@v5
|
||||
# with:
|
||||
# context: .
|
||||
# build-args: ${{ matrix.build-args }}
|
||||
# push: false
|
||||
# build-contexts: ${{ matrix.build-contexts }}
|
||||
# file: ${{ matrix.dockerfile }}
|
||||
# cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }}
|
||||
# cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }}
|
||||
# platforms: linux/amd64
|
||||
# labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: Nightly build and push from develop branch
|
||||
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }}
|
||||
|
|
@ -167,3 +169,14 @@ jobs:
|
|||
cache-to: type=gha,mode=max,scope=rpxy-latest-${{ matrix.target }}
|
||||
platforms: ${{ matrix.platforms }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
dispatch_release_event:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
|
||||
needs: build_and_push
|
||||
steps:
|
||||
- name: Repository dispatch for release
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
event-type: release-event
|
||||
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "pull_request": { "title": "${{ github.event.pull_request.title }}", "body": "${{ github.event.pull_request.body }}", "number": "${{ github.event.pull_request.number }}", "head": "${{ github.event.pull_request.head.ref }}", "base": "${{ github.event.pull_request.base.ref}}"}}'
|
||||
|
|
|
|||
50
.github/workflows/release.yml
vendored
50
.github/workflows/release.yml
vendored
|
|
@ -8,11 +8,14 @@ on:
|
|||
branches:
|
||||
- main
|
||||
- develop
|
||||
repository_dispatch:
|
||||
types:
|
||||
- release-event
|
||||
|
||||
jobs:
|
||||
on-success:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} || ${{ github.event_name == 'pull_request' }}
|
||||
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} || ${{ github.event_name == 'repositry_dispatch' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
@ -103,47 +106,42 @@ jobs:
|
|||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
# if: ${{ github.ref_name == 'main' }}
|
||||
if: ${{ github.event_name == 'repository_dispatch' }}
|
||||
needs: on-success
|
||||
steps:
|
||||
# - name: check pull_request title
|
||||
# uses: actions-ecosystem/action-regex-match@v2
|
||||
# id: regex-match
|
||||
# with:
|
||||
# text: ${{ github.event.pull_request.title }}
|
||||
# regex: "^(\\d+\\.\\d+\\.\\d+)$"
|
||||
- name: retrive github script context
|
||||
uses: actions/github-script@v6
|
||||
- name: check pull_request title
|
||||
uses: kaisugi/action-regex-match@v1.0.0
|
||||
id: regex-match
|
||||
with:
|
||||
script: |
|
||||
core.info(JSON.stringify(context.payload))
|
||||
text: ${{ github.event.client_payload.pull_request.title }}
|
||||
regex: "^(\\d+\\.\\d+\\.\\d+)$"
|
||||
|
||||
- name: checkout
|
||||
# if: ${{ steps.regex-match.outputs.match != '' }}
|
||||
if: ${{ steps.regex-match.outputs.match != '' }}
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download artifacts
|
||||
# if: ${{ steps.regex-match.outputs.match != ''}}
|
||||
if: ${{ steps.regex-match.outputs.match != ''}}
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: /tmp/rpxy
|
||||
|
||||
- name: make tar.gz of assets
|
||||
# if: ${{ steps.regex-match.outputs.match != ''}}
|
||||
if: ${{ steps.regex-match.outputs.match != ''}}
|
||||
run: |
|
||||
mkdir /tmp/assets
|
||||
cd /tmp/rpxy
|
||||
for i in ./*; do sh -c "cd $i && tar zcvf $i.tar.gz $i && mv $i.tar.gz /tmp/assets/"; done
|
||||
ls -lha /tmp/assets
|
||||
|
||||
# - name: release
|
||||
# if: ${{ steps.regex-match.outputs.match != ''}}
|
||||
# uses: softprops/action-gh-release@v1
|
||||
# with:
|
||||
# files: /tmp/assets/*.tar.gz
|
||||
# name: ${{ github.event.pull_request.title }}
|
||||
# tag_name: ${{ github.event.pull_request.title }}
|
||||
# body: ${{ github.event.pull_request.body }}
|
||||
# draft: true
|
||||
# prerelease: false
|
||||
# generate_release_notes: true
|
||||
- name: release
|
||||
if: ${{ steps.regex-match.outputs.match != ''}}
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: /tmp/assets/*.tar.gz
|
||||
name: ${{ github.event.client_payload.pull_request.title }}
|
||||
tag_name: ${{ github.event.client_payload.pull_request.title }}
|
||||
body: ${{ github.event.client_payload.pull_request.body }}
|
||||
draft: true
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue