Skip to content

Docker CI

Docker CI #103

Workflow file for this run

name: Docker CI
# Controls when the workflow will run
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
push:
branches: [ "main" ]
concurrency:
group: "pytorch"
cancel-in-progress: false
jobs:
build-matrix:
runs-on: ubuntu-latest
steps:
- id: set-matrix
run: echo "version_matrix=$(curl https://api.github.com/repos/pytorch/pytorch/releases | jq -r '.[]["tag_name"]' | sed s/v// | jq -Rcn '[inputs]')" >> $GITHUB_OUTPUT
outputs:
version_matrix: ${{ steps.set-matrix.outputs.version_matrix }}
run:
needs: build-matrix
runs-on: ubuntu-latest
strategy:
matrix:
version: ${{ fromJson(needs.build-matrix.outputs.version_matrix) }}
fail-fast: false
permissions: write-all
steps:
- name: chown and chmod to allow editing the cache dir
run: |
sudo chmod -R 777 /var/lib/docker/ || exit 0
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
id: cache-restore
with:
path: /var/lib/docker/volumes/ccache/_data
key: ${{ runner.os }}-${{ matrix.version }}
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
run: |
echo ${{ secrets.GHCR_PAT }} | docker login ghcr.io -u PiMachineLearning --password-stdin
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Build Pytorch
run: |
cd $GITHUB_WORKSPACE
sudo apt-get install -y qemu-user-static binfmt-support
chmod +x main.sh
./main.sh ${{ matrix.version }}
env:
VPS_HOST: ${{ secrets.VPS_HOST }}
- name: Evict caches
run: |
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/PiMachineLearning/pitorch/actions/caches?key=${{ runner.os }}-${{ matrix.version }} || exit 0
if: always()
- uses: actions/cache/save@v3
id: cache-save
if: always()
with:
path: /var/lib/docker/volumes/ccache/_data
key: ${{ runner.os }}-${{ matrix.version }}