Restore pinned packages for sb2 that is using GYM #9
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: Build and push agents images | |
on: | |
push: {} | |
workflow_dispatch: {} | |
workflow_call: {} | |
jobs: | |
generate-matrix: | |
name: Generate build matrix | |
runs-on: ubuntu-22.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: diambra/agents | |
fetch-depth: 0 | |
- id: set-matrix | |
run: echo "::set-output name=matrix::$(./.github/workflows/generate-image-build-matrix basic/* *)" | |
checkout_and_download_lfs: | |
name: Checkout and Download LFS | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout selected branch | |
uses: actions/checkout@v3 | |
with: | |
repository: diambra/agents | |
lfs: true | |
- name: Store repo with LFS files as artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: repo-lfs-artifacts | |
path: . # You can specify the path to the LFS files if they are in a specific directory | |
build-and-push-images: | |
needs: [generate-matrix, checkout_and_download_lfs] | |
runs-on: ubuntu-latest | |
if: ${{ needs.generate-matrix.outputs.matrix != '[]' }} | |
strategy: | |
fail-fast: true | |
matrix: | |
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
steps: | |
- name: Restore repo with LFS files from artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: repo-lfs-artifacts | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.io | |
username: diambrabot | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to Quay | |
uses: docker/login-action@v2 | |
with: | |
registry: quay.io | |
username: diambra+github | |
password: ${{ secrets.QUAY_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/diambra/agent-${{ matrix.name }} | |
docker.io/diambra/agent-${{ matrix.name }} | |
quay.io/diambra/agent-${{ matrix.name }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}}.{{minor}} | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Find base tag | |
id: base-tag | |
run: | | |
semver=${{ steps.meta.outputs.version }} | |
major=${semver%%.*} | |
# If not a semver (e.g branch name), use main as base tag | |
if [[ $major == "$semver" ]]; then | |
echo "tag=main" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
minor_and_patch=${semver#*.} | |
minor=${minor_and_patch%%.*} | |
echo "tag=v${major}.${minor}" >> "$GITHUB_OUTPUT" | |
- name: Build and push agent ${{ matrix.dir }} | |
uses: docker/build-push-action@v3 | |
with: | |
context: ${{ matrix.dir }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
TAG=${{ steps.base-tag.outputs.tag }} |