Caching Env Example #1954
This file contains hidden or 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: "Caching Env Example" | |
| on: | |
| pull_request: | |
| branches: | |
| - "*" | |
| push: | |
| branches: | |
| - "develop" | |
| - "main" | |
| - "master" | |
| schedule: | |
| # Note that cronjobs run on master/main by default | |
| - cron: "0 0 * * *" | |
| concurrency: | |
| group: | |
| ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| jobs: | |
| caching-example: | |
| name: Caching-Env | |
| # prevent cronjobs from running on forks | |
| if: | |
| (github.event_name == 'schedule' && github.repository == | |
| 'conda-incubator/setup-miniconda') || (github.event_name != 'schedule') | |
| strategy: | |
| matrix: | |
| os: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/[email protected] | |
| - name: Setup Miniforge | |
| uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 | |
| with: | |
| miniforge-version: latest | |
| activate-environment: anaconda-client-env | |
| use-mamba: true | |
| - name: Get Date | |
| id: get-date | |
| run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')" | |
| shell: bash | |
| - name: Cache Conda env | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.CONDA }}/envs | |
| key: | |
| conda-${{ runner.os }}--${{ runner.arch }}--${{ | |
| steps.get-date.outputs.today }}-${{ | |
| hashFiles('etc/example-environment-caching.yml') }}-${{ | |
| env.CACHE_NUMBER }} | |
| env: | |
| # Increase this value to reset cache if etc/example-environment.yml has not changed | |
| CACHE_NUMBER: 0 | |
| id: cache | |
| - name: Update environment | |
| run: | |
| conda env update -n anaconda-client-env -f | |
| etc/example-environment-caching.yml | |
| if: steps.cache.outputs.cache-hit != 'true' |