Skip to content

Commit

Permalink
add CI to deploy ioc-template-example
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Aug 1, 2024
1 parent f321f98 commit f71ebd8
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
workflow_call:
outputs:
branch-pr:
description: The PR number if the branch is in one
value: ${{ jobs.pr.outputs.branch-pr }}

jobs:
pr:
runs-on: "ubuntu-latest"
outputs:
branch-pr: ${{ steps.script.outputs.result }}
steps:
- uses: actions/github-script@v7
id: script
if: github.event_name == 'push'
with:
script: |
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: context.repo.owner + ':${{ github.ref_name }}'
})
if (prs.data.length) {
console.log(`::notice ::Skipping CI on branch push as it is already run in PR #${prs.data[0]["number"]}`)
return prs.data[0]["number"]
}
34 changes: 34 additions & 0 deletions .github/workflows/_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
workflow_call:
secrets:
EXAMPLE_DEPLOY_KEY:
required: true
jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0

- name: Regenerate example
run: |
pipx run copier copy --data-file example-answers.yml --trust --vcs-ref=HEAD . example
- name: Rewrite copier answers
run: |
sed -i 's|_src_path: .|_src_path: gh:epics-containers/ioc-template|' example/.copier-answers.yml
- name: Publish example
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
deploy_key: ${{ secrets.EXAMPLE_DEPLOY_KEY }}
publish_dir: example
external_repository: epics-containers/ioc-template-example
publish_branch: main
exclude_assets: '' # default would exclude .github
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

on:
push:
pull_request:

jobs:
check:
uses: ./.github/workflows/_check.yml

example:
needs: test
if: github.ref_name == 'main'
uses: ./.github/workflows/_example.yml
secrets:
EXAMPLE_DEPLOY_KEY: ${{ secrets.EXAMPLE_DEPLOY_KEY }}
9 changes: 9 additions & 0 deletions example-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 3.5.0
_src_path: ioc-template
description: A test instantiation of the ioc-template copier template
git_platform: github.com
github_org: epics-containers
name: ioc-template-example
repo_uri: [email protected]:epics-containers/ioc-template-example.git
rtems: false

0 comments on commit f71ebd8

Please sign in to comment.