chore: remove pr template #369
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cache | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
# tl;dr; | |
# push will diff with cache, and dispatch workflow. | |
# workflow_dispatch without any repo change will use cache, and not dispatch workflow. | |
env: | |
DISPATCH_REPO: guitarrapc/testtest | |
DIPATCH_WORKFLOW_NAME: test | |
DISPATCH_BRANCH: main | |
CACHE_VERSION: v1 | |
jobs: | |
detect_library_change: | |
runs-on: ubuntu-latest | |
outputs: | |
cache-hit: ${{ steps.cache-sha.outputs.cache-hit }} | |
timeout-minutes: 10 | |
steps: | |
- name: Dump GitHub context | |
run: echo "$CONTEXT" | |
env: | |
CONTEXT: ${{ toJson(github) }} | |
# get trigger repo references | |
- name: public repo reference | |
uses: actions/github-script@v3 | |
id: set-public-result | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const result = await github.git.getRef({ | |
owner: context.repo.owner, | |
repo: "githubactions-lab", | |
ref: "heads/main" | |
}) | |
console.log(result) | |
return result.data.object.sha | |
- run: echo "${{ steps.set-public-result.outputs.result }}" | |
- name: private repo reference | |
uses: actions/github-script@v3 | |
id: set-private-result | |
with: | |
github-token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} # must be PAT | |
script: | | |
const result = await github.git.getRef({ | |
owner: context.repo.owner, | |
repo: "testtest", | |
ref: "heads/main" | |
}) | |
console.log(result) | |
return result.data.object.sha | |
- run: echo "${{ steps.set-private-result.outputs.result }}" | |
# write all repo's sha to single file | |
- name: gen sha hash | |
run: | | |
mkdir ./cache/ | |
cat <<EOF > ./cache/sha.txt | |
${{ steps.set-public-result.outputs.result }} | |
${{ steps.set-private-result.outputs.result }} | |
EOF | |
# cache validation if sha's file has been updated | |
- name: Cache sha | |
id: cache-sha | |
uses: actions/cache@v2 | |
with: | |
path: ~/cache | |
key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-sha-${{ hashFiles('**/sha.txt') }} | |
dispatch: | |
needs: [detect_library_change] | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.detect_library_change.outputs.cache-hit != 'true' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
# dispatch build if cache is not match with previous | |
- uses: benc-uk/workflow-dispatch@v1.1 | |
with: | |
repo: ${{ env.DISPATCH_REPO }} | |
ref: ${{ env.DISPATCH_BRANCH }} | |
workflow: ${{ env.DIPATCH_WORKFLOW_NAME }} | |
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} |