|
6 | 6 |
|
7 | 7 | jobs:
|
8 | 8 | Caching_CVAT:
|
| 9 | + env: |
| 10 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 11 | + REPO: ${{ github.repository }} |
9 | 12 | runs-on: ubuntu-latest
|
10 | 13 | steps:
|
11 | 14 | - uses: actions/checkout@v2
|
12 |
| - - uses: actions/cache@v2 |
| 15 | + |
| 16 | + - name: Getting SHA with cache from the default branch |
| 17 | + id: get-sha |
| 18 | + run: | |
| 19 | + DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch') |
| 20 | + for sha in $(gh api "/repos/$REPO/commits?per_page=100&sha=${DEFAULT_BRANCH}" | jq -r '.[].sha'); |
| 21 | + do |
| 22 | + RUN_status=$(gh api /repos/${REPO}/actions/workflows/cache.yml/runs | \ |
| 23 | + jq -r ".workflow_runs[]? | select((.head_sha == \"${sha}\") and (.conclusion == \"success\")) | .status") |
| 24 | +
|
| 25 | + if [[ ${RUN_status} == "completed" ]]; then |
| 26 | + SHA=$sha |
| 27 | + break |
| 28 | + fi |
| 29 | + done |
| 30 | +
|
| 31 | + echo Default branch is ${DEFAULT_BRANCH} |
| 32 | + echo Workflow will try to get cache from commit: ${SHA} |
| 33 | +
|
| 34 | + echo ::set-output name=default_branch::${DEFAULT_BRANCH} |
| 35 | + echo ::set-output name=sha::${SHA} |
| 36 | +
|
| 37 | + - uses: actions/cache@v3 |
| 38 | + id: server-cache-action |
13 | 39 | with:
|
14 | 40 | path: /tmp/cvat_cache_server
|
15 | 41 | key: ${{ runner.os }}-build-server-${{ github.sha }}
|
16 | 42 | restore-keys: |
|
| 43 | + ${{ runner.os }}-build-server-${{ steps.get-sha.outputs.sha }} |
17 | 44 | ${{ runner.os }}-build-server-
|
18 | 45 |
|
19 |
| - - uses: actions/cache@v2 |
| 46 | + - uses: actions/cache@v3 |
| 47 | + id: ui-cache-action |
20 | 48 | with:
|
21 | 49 | path: /tmp/cvat_cache_ui
|
22 | 50 | key: ${{ runner.os }}-build-ui-${{ github.sha }}
|
23 | 51 | restore-keys: |
|
| 52 | + ${{ runner.os }}-build-ui-${{ steps.get-sha.outputs.sha }} |
24 | 53 | ${{ runner.os }}-build-ui-
|
25 | 54 |
|
| 55 | + - uses: actions/cache@v3 |
| 56 | + id: elasticsearch-cache-action |
| 57 | + with: |
| 58 | + path: /tmp/cvat_cache_elasticsearch |
| 59 | + key: ${{ runner.os }}-build-elasticsearch-${{ github.sha }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-build-elasticsearch-${{ steps.get-sha.outputs.sha }} |
| 62 | + ${{ runner.os }}-build-elasticsearch- |
| 63 | +
|
| 64 | + - uses: actions/cache@v3 |
| 65 | + id: logstash-cache-action |
| 66 | + with: |
| 67 | + path: /tmp/cvat_cache_logstash |
| 68 | + key: ${{ runner.os }}-build-logstash-${{ github.sha }} |
| 69 | + restore-keys: | |
| 70 | + ${{ runner.os }}-build-logstash-${{ steps.get-sha.outputs.sha }} |
| 71 | + ${{ runner.os }}-build-logstash- |
| 72 | +
|
26 | 73 | - name: Set up Docker Buildx
|
27 |
| - uses: docker/setup-buildx-action@v1.1.2 |
| 74 | + uses: docker/setup-buildx-action@v2 |
28 | 75 |
|
29 |
| - - name: Caching CVAT server |
| 76 | + - name: Caching CVAT Server |
30 | 77 | uses: docker/build-push-action@v2
|
31 | 78 | with:
|
32 | 79 | context: .
|
|
42 | 89 | cache-from: type=local,src=/tmp/cvat_cache_ui
|
43 | 90 | cache-to: type=local,dest=/tmp/cvat_cache_ui-new
|
44 | 91 |
|
| 92 | + - name: Caching CVAT Elasticsearch |
| 93 | + uses: docker/build-push-action@v2 |
| 94 | + with: |
| 95 | + context: ./components/analytics/elasticsearch/ |
| 96 | + file: ./components/analytics/elasticsearch/Dockerfile |
| 97 | + cache-from: type=local,src=/tmp/cvat_cache_elasticsearch |
| 98 | + cache-to: type=local,dest=/tmp/cvat_cache_elasticsearch-new |
| 99 | + build-args: ELK_VERSION=6.8.23 |
| 100 | + |
| 101 | + - name: Caching CVAT Logstash |
| 102 | + uses: docker/build-push-action@v2 |
| 103 | + with: |
| 104 | + context: ./components/analytics/logstash/ |
| 105 | + file: ./components/analytics/logstash/Dockerfile |
| 106 | + cache-from: type=local,src=/tmp/cvat_cache_logstash |
| 107 | + cache-to: type=local,dest=/tmp/cvat_cache_logstash-new |
| 108 | + build-args: ELK_VERSION=6.8.23 |
| 109 | + |
45 | 110 | - name: Moving cache
|
46 | 111 | run: |
|
47 | 112 | rm -rf /tmp/cvat_cache_server
|
48 | 113 | mv /tmp/cvat_cache_server-new /tmp/cvat_cache_server
|
| 114 | +
|
49 | 115 | rm -rf /tmp/cvat_cache_ui
|
50 | 116 | mv /tmp/cvat_cache_ui-new /tmp/cvat_cache_ui
|
| 117 | +
|
| 118 | + rm -rf /tmp/cvat_cache_elasticsearch |
| 119 | + mv /tmp/cvat_cache_elasticsearch-new /tmp/cvat_cache_elasticsearch |
| 120 | +
|
| 121 | + rm -rf /tmp/cvat_cache_logstash |
| 122 | + mv /tmp/cvat_cache_logstash-new /tmp/cvat_cache_logstash |
0 commit comments