Docker #1403
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: Docker | |
on: | |
push: | |
schedule: | |
- cron: '0 */11 * * *' | |
jobs: | |
check-updates: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.outputs.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
id: "rust-toolchain" | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/git | |
~/.cargo/registry | |
targe | |
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} Lock ${{hashFiles('Cargo.lock')}}" | |
- run: cargo run | |
id: outputs | |
env: | |
RUST_BACKTRACE: 1 | |
docker: | |
runs-on: ubuntu-latest | |
needs: [check-updates] | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.check-updates.outputs.matrix) }} | |
name: build '${{ matrix.name }}' | |
steps: | |
- name: Echo matrix | |
if: ${{ matrix.skip != 'true' }} | |
run: | | |
echo 'version=${{ matrix.version }}' | |
echo 'path=${{ matrix.path }}' | |
echo 'name=${{ matrix.name }}' | |
echo 'test=${{ matrix.test }}' | |
echo 'platforms=${{ matrix.platforms }}' | |
echo 'docker_tags=${{ matrix.docker_tags }}' | |
echo 'index=${{ matrix.index }}' | |
- uses: actions/checkout@v3 | |
if: ${{ matrix.skip != 'true' }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
if: ${{ matrix.skip != 'true' }} | |
- name: Login to GitHub Container Registry | |
if: ${{ matrix.skip != 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
if: ${{ matrix.skip != 'true' && matrix.platforms != 'linux/amd64' }} | |
uses: docker/setup-qemu-action@v2 | |
- name: Docker meta | |
if: ${{ matrix.skip != 'true' }} | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ format('ghcr.io/{0}/{1}', github.repository_owner, matrix.name) }} | |
tags: ${{ matrix.docker_tags }} | |
- name: Build and push | |
if: ${{ matrix.skip != 'true' }} | |
uses: docker/build-push-action@v3 | |
with: | |
context: ${{ matrix.path }} | |
push: ${{ github.ref == 'refs/heads/main' || matrix.test }} | |
build-args: version=${{ matrix.version }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }}} | |
platforms: ${{ matrix.platforms }} | |
- name: update index.json | |
if: ${{ matrix.skip != 'true' }} | |
run: echo '${{ matrix.index }}' > ${{ format('{0}/index.json', matrix.path) }} | |
- name: push index.json | |
if: ${{ matrix.skip != 'true' }} | |
run: | | |
git config --global user.name 'CI' | |
git config --global user.email 'CI' | |
git config --global pull.rebase true | |
git add -f ${{ format('{0}/index.json', matrix.path) }} | |
git commit -m '${{ format('update {0} to {1}', matrix.name, matrix.version) }}' ${{ format('{0}/index.json', matrix.path) }} | |
git pull | |
git push |