Skip to content

Commit

Permalink
ci(actions): separate push and pull request actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbertix committed May 20, 2021
1 parent b496be6 commit 4b2da5b
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 163 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: pull_request

on:
pull_request:
types:
- opened
- synchronize

jobs:
# pull request-sepcific steps.
validate_commits:
name: Conventional Commits
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
# validate commits.
- name: Validate commits
uses: KevinDeJong-TomTom/commisery-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull_request: ${{ github.event.number }}

# update the pull request message body.
update_body:
name: Changelog
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# create the changelog.
- name: Changelog
id: changelog
uses: nblagoev/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head-ref: ${{ github.event.pull_request.head.sha }}
base-ref: ${{ github.event.pull_request.base.sha }}
# update the pull request message body.
- name: Update Pull Request Description
uses: riskledger/update-pr-description@v2
with:
body: ${{ steps.changelog.outputs.result }}
token: ${{ secrets.GITHUB_TOKEN }}

# lint code.
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
# only lint on actual code changes.
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '**/*.swift'
- name: Lint
if: steps.changes.outputs.src == 'true'
uses: norio-nomura/[email protected]
with:
args: --strict

# build the library.
build:
name: Build
needs: lint
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v2
# only build on actual code changes.
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '**/*.swift'
- name: Build
if: steps.changes.outputs.src == 'true'
run: swift build
182 changes: 120 additions & 62 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,145 @@
name: checks
name: release

on:
pull_request:
types:
- opened
- synchronize
push:
branches:
- main

jobs:
# pull request-sepcific steps.
pull_request:
name: Pull request
runs-on: ubuntu-latest
if: ${{ github.event.number }}

steps:
- name: Checkout
uses: actions/checkout@v2
# validate commits.
- name: Validate commits
uses: KevinDeJong-TomTom/commisery-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull_request: ${{ github.event.number }}
# create the changelog.
- name: Changelog
id: changelog
uses: mrchief/[email protected]
with:
previousReleaseTagNameOrSha: ${{ github.event.pull_request.base.sha }}
nextReleaseTagName: ${{ github.event.number }}
nextReleaseName: ${{ github.event.number }}
# update the pull request message body.
- name: Update Pull Request Description
if: ${{ steps.changelog.outputs.changelog }}
uses: riskledger/update-pr-description@v2
with:
body: ${{ steps.changelog.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}

# lint code.
lint:
name: Lint
runs-on: ubuntu-latest
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
# only lint on actual code changes.
- uses: dorny/paths-filter@v2
id: changes
- uses: dorny/paths-filter@v2
id: changes
with:
base: ${{ github.event.pull_request.base.sha || github.event.push.before }}
ref: ${{ github.event.pull_request.head.sha || github.event.push.head }}
filters: |
base: ${{ github.event.push.before }}
filters: |
src:
- '**/*.swift'
- name: Lint
if: steps.changes.outputs.src == 'true'
uses: norio-nomura/[email protected]
- name: Lint
if: steps.changes.outputs.src == 'true'
uses: norio-nomura/[email protected]
with:
args: --strict
args: --strict

# build the library.
build:
name: Build
needs: lint
runs-on: macos-latest
name: Build
needs: lint
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
# only build on actual code changes.
- uses: dorny/paths-filter@v2
id: changes
- uses: dorny/paths-filter@v2
id: changes
with:
base: ${{ github.event.pull_request.base.sha || github.event.push.before }}
ref: ${{ github.event.pull_request.head.sha || github.event.push.head }}
filters: |
base: ${{ github.event.push.before }}
filters: |
src:
- '**/*.swift'
- name: Build
if: steps.changes.outputs.src == 'true'
run: swift build
- name: Build
if: steps.changes.outputs.src == 'true'
run: swift build

# release a new version.
release:
name: Release
needs: build
runs-on: ubuntu-latest

steps:
# checkout `main`.
- name: Checkout
id: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ref: main
# create the changelog.
- name: Changelog
id: changelog
uses: TriPSs/conventional-changelog-action@v3
with:
git-message: "chore(release): relase \'v{version}\'"
git-user-name: "github-actions"
git-user-email: "41898282+github-actions[bot]@users.noreply.github.com"
github-token: ${{ secrets.GITHUB_TOKEN }}
tag-prefix: ''
output-file: 'false'
skip-commit: 'true'
skip-version-file: 'true'
# release the new version.
- name: Release
id: release
uses: actions/create-release@v1
if: ${{ steps.changelog.outputs.skipped == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: v${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
# notify on telegram.
- name: Telegram
if: ${{ steps.changelog.outputs.skipped == 'false' }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
args: |
A [new version](${{ steps.release.outputs.html_url }}) of **Swiftagram** was just released.
Please consider updating your code.
continue-on-error: true

# create docs.
docs:
name: Docs
needs: release
runs-on: ubuntu-latest

steps:
# checkout the `main` branch.
- name: Checkout
id: checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: main
# create documentation for `Swiftagram`.
- name: Docs (Swiftagram)
uses: SwiftDocOrg/swift-doc@master
with:
base-url: "https://sbertix.github.io/Swiftagram/Swiftagram/"
format: "html"
inputs: "Sources"
module-name: Swiftagram
output: docs/Swiftagram
# create documentation for `SwiftagramCrypto`.
- name: Docs (SwiftagramCrypto)
uses: SwiftDocOrg/swift-doc@master
with:
base-url: "https://sbertix.github.io/Swiftagram/SwiftagramCrypto/"
format: "html"
inputs: "Sources"
module-name: SwiftagramCrypto
output: docs/SwiftagramCrypto
# update permissions.
- name: Update Permissions
run: 'sudo chown --recursive $USER docs'
# publish to GitHub pages.
- name: Publish
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.CHATOPS_PAT }}
BRANCH: gh-pages
FOLDER: docs
Loading

0 comments on commit 4b2da5b

Please sign in to comment.