diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d99b23355..69d9f8fae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,8 @@ env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release MAKEFLAGS: "-j8" + DOCKER_REPO: ${{ secrets.DOCKER_REPO }} + REPO_OWNER: ${{ github.repository_owner }} # Multiple job to tests jobs: @@ -24,6 +26,7 @@ jobs: source_modified: ${{ steps.changes.outputs.status_code == '1' }} force_upload: false sha_short: ${{ steps.changes.outputs.sha_short }} + docker_repo: ${{ steps.changes.outputs.docker_repo }} steps: - name: Checkout OpenFPGA repo uses: actions/checkout@v2 @@ -43,14 +46,22 @@ jobs: echo "Current brnach is master forcing source_modified" echo "::set-output name=status_code::1" fi + if [[ -n "${DOCKER_REPO}" ]]; then + echo "name=docker_repo::$DOCKER_REPO" + echo "::set-output name=docker_repo::$DOCKER_REPO" + else + echo "name=docker_repo::$REPO_OWNER" + echo "::set-output name=docker_repo::$REPO_OWNER" + fi echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + # Test the compilation compatibility linux_build: needs: change_detect if: ${{ fromJSON(needs.change_detect.outputs.source_modified) }} name: ${{ matrix.config.name }} runs-on: ubuntu-18.04 - container: ghcr.io/${{ github.repository_owner }}/openfpga-build-${{ matrix.config.cc}} + container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-${{ matrix.config.cc}} # Branch on different OS and settings strategy: fail-fast: false @@ -194,12 +205,12 @@ jobs: file: ./docker/Dockerfile.master push: ${{ github.ref == 'refs/heads/master' || needs.change_detect.outputs.force_upload }} tags: | - ghcr.io/${{github.repository_owner}}/openfpga-master:latest - ghcr.io/${{github.repository_owner}}/openfpga-master:${{ needs.change_detect.outputs.sha_short }} + ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-master:latest + ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-master:${{ needs.change_detect.outputs.sha_short }} linux_regression_tests: name: linux_regression_tests runs-on: ubuntu-18.04 - container: ghcr.io/${{github.repository_owner}}/openfpga-env + container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-env needs: linux_build strategy: fail-fast: false @@ -248,7 +259,7 @@ jobs: if: ${{ !fromJSON(needs.change_detect.outputs.source_modified) }} name: docker_regression_tests runs-on: ubuntu-18.04 - container: ghcr.io/${{github.repository_owner}}/openfpga-master:latest + container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-master:latest strategy: fail-fast: false matrix: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d51cf1120..27bbf3d42 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,12 @@ name: Build docker CI images on: - workflow_dispatch + +# Environment variables +env: + DOCKER_REPO: ${{ secrets.DOCKER_REPO }} + REPO_OWNER: ${{ github.repository_owner }} + jobs: base_images: name: Push Docker images @@ -8,6 +14,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Check for source code changes + id: changes + run: | + if [[ -n "${DOCKER_REPO}" ]]; then + echo "name=docker_repo::$DOCKER_REPO" + echo "::set-output name=docker_repo::$DOCKER_REPO" + else + echo "name=docker_repo::$REPO_OWNER" + echo "::set-output name=docker_repo::$REPO_OWNER" + fi - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -16,7 +32,7 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ github.repository_owner }} + username: ${{ needs.change_detect.outputs.docker_repo }} password: ${{ secrets.CR_PAT }} - name: Build base uses: docker/build-push-action@v2 @@ -24,14 +40,14 @@ jobs: context: . file: ./docker/Dockerfile.base push: true - tags: ghcr.io/${{ github.repository_owner }}/openfpga-build-base:latest + tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-base:latest - name: Build environment image uses: docker/build-push-action@v2 with: context: . file: ./docker/Dockerfile.env push: true - tags: ghcr.io/${{ github.repository_owner }}/openfpga-env:latest + tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-env:latest compiler_images: name: Build ${{ matrix.compiler }} compiler image needs: base_images @@ -57,7 +73,7 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ github.repository_owner }} + username: ${{ needs.change_detect.outputs.docker_repo }} password: ${{ secrets.CR_PAT }} - name: Build ${{ matrix.compiler }} image uses: docker/build-push-action@v2 @@ -65,4 +81,4 @@ jobs: context: . file: ./docker/Dockerfile.${{ matrix.compiler }} push: true - tags: ghcr.io/${{ github.repository_owner }}/openfpga-build-${{ matrix.compiler }}:latest + tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-${{ matrix.compiler }}:latest