Skip to content

Commit

Permalink
Cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
vinocher-bc authored Aug 30, 2024
1 parent f284689 commit 16405b5
Showing 1 changed file with 13 additions and 66 deletions.
79 changes: 13 additions & 66 deletions .github/workflows/0-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,73 +19,20 @@ permissions:

jobs:
# Get the current step to only run the main job when the learner is on the same step.
get_current_step:
name: Check current step number
runs-on: ubuntu-latest
cacheTest:
name: Test Cache
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- id: get_step
run: |
echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_start:
name: On start
needs: get_current_step

# We will only run this action when:
# 1. This repository isn't the template repository.
# 2. The step is currently 0.
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 0 }}
# We'll run Ubuntu for performance instead of Mac or Windows.
runs-on: ubuntu-latest

steps:
# We'll need to check out the repository so that we can edit the README.
- name: Checkout
uses: actions/checkout@v4
- name: Check GitHub Cache
uses: actions/cache/restore@v4
id: check_cache
with:
fetch-depth: 0 # Let's get all the branches.
key: "foo"
path: .
lookup-only: true

# Make a branch, file, and commit for the learner.
- name: Prepare a branch, and file
- name: Debug Cache
shell: pwsh
run: |
echo "Make sure we are on step 0"
if [ "$(cat .github/steps/-step.txt)" != 0 ]
then
echo "Current step is not 0"
exit 0
fi
echo "Make a branch"
BRANCH=welcome-workflow
git checkout -b $BRANCH
echo "Make a commit"
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git commit --allow-empty --message="Create an empty commit"
echo "Push"
git push --set-upstream origin $BRANCH
echo "Restore main"
git checkout main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# In README.md, switch step 0 for step 1.
- name: Update to step 1
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 0
to_step: 1
branch_name: welcome-workflow
echo "cache hit: ${{ steps.check_cache.outputs.cache-hit }}"

0 comments on commit 16405b5

Please sign in to comment.