Merge pull request #103 from junkurihara/fix/release-actions

fix: release actions
This commit is contained in:
Jun Kurihara 2023-10-13 00:04:42 +09:00 committed by GitHub
commit 119eb7f7d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 27 deletions

View file

@ -1,11 +1,12 @@
name: Build and publish docker name: Build and publish docker, and trigger release
on: on:
push: push:
branches: branches:
- "develop" - "develop"
- "main"
pull_request: pull_request:
types: [synchronize, opened] types: [closed]
branches:
- main
env: env:
GHCR: ghcr.io GHCR: ghcr.io
@ -15,6 +16,7 @@ env:
jobs: jobs:
build_and_push: build_and_push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -119,19 +121,19 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Nightly build test on amd64 for pull requests # - name: Nightly build test on amd64 for pull requests
if: ${{ github.event_name == 'pull_request' }} # if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v5 # uses: docker/build-push-action@v5
with: # with:
context: . # context: .
build-args: ${{ matrix.build-args }} # build-args: ${{ matrix.build-args }}
push: false # push: false
build-contexts: ${{ matrix.build-contexts }} # build-contexts: ${{ matrix.build-contexts }}
file: ${{ matrix.dockerfile }} # file: ${{ matrix.dockerfile }}
cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }} # cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }}
cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }} # cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }}
platforms: linux/amd64 # platforms: linux/amd64
labels: ${{ steps.meta.outputs.labels }} # labels: ${{ steps.meta.outputs.labels }}
- name: Nightly build and push from develop branch - name: Nightly build and push from develop branch
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }} 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 }} cache-to: type=gha,mode=max,scope=rpxy-latest-${{ matrix.target }}
platforms: ${{ matrix.platforms }} platforms: ${{ matrix.platforms }}
labels: ${{ steps.meta.outputs.labels }} 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}}"}}'

View file

@ -8,15 +8,14 @@ on:
branches: branches:
- main - main
- develop - develop
pull_request: repository_dispatch:
types: [closed] types:
branches: - release-event
- main
jobs: jobs:
on-success: on-success:
runs-on: ubuntu-latest 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: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -107,14 +106,14 @@ jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }} if: ${{ github.event_name == 'repository_dispatch' }}
needs: on-success needs: on-success
steps: steps:
- name: check pull_request title - name: check pull_request title
uses: actions-ecosystem/action-regex-match@v2 uses: kaisugi/action-regex-match@v1.0.0
id: regex-match id: regex-match
with: with:
text: ${{ github.event.pull_request.title }} text: ${{ github.event.client_payload.pull_request.title }}
regex: "^(\\d+\\.\\d+\\.\\d+)$" regex: "^(\\d+\\.\\d+\\.\\d+)$"
- name: checkout - name: checkout
@ -140,9 +139,9 @@ jobs:
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
files: /tmp/assets/*.tar.gz files: /tmp/assets/*.tar.gz
name: ${{ github.event.pull_request.title }} name: ${{ github.event.client_payload.pull_request.title }}
tag_name: ${{ github.event.pull_request.title }} tag_name: ${{ github.event.client_payload.pull_request.title }}
body: ${{ github.event.pull_request.body }} body: ${{ github.event.client_payload.pull_request.body }}
draft: true draft: true
prerelease: false prerelease: false
generate_release_notes: true generate_release_notes: true