chore: update github actions, #22
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 Flutter App Version | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Generate random number | |
id: random | |
run: echo "RANDOM_NUMBER=$(shuf -i 1-100 -n 1)" >> $GITHUB_ENV | |
- name: Restore version from cache | |
id: cache | |
uses: actions/cache@v2 | |
with: | |
path: cached_value.txt | |
key: cached-value | |
- name: Compare cached value | |
run: | | |
if [ -f cached_value.txt ]; then | |
cached_value=$(cat cached_value.txt) | |
echo "Cached value: $cached_value" | |
if [ "$cached_value" != "${{ env.RANDOM_NUMBER }}" ]; then | |
echo "CACHE_CHANGED=true" >> $GITHUB_ENV | |
else | |
echo "CACHE_CHANGED=false" >> $GITHUB_ENV | |
fi | |
else | |
echo "CACHE_CHANGED=true" >> $GITHUB_ENV | |
fi | |
- name: Save random number to cache | |
if: env.CACHE_CHANGED == 'true' | |
run: echo "${{ env.RANDOM_NUMBER }}" > cached_value.txt |