diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 77ccb1527..dcb4ac4cd 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::$REPO_OWNER" + echo "::set-output name=docker_repo::$REPO_OWNER" + else + echo "name=docker_repo::lnis-uofu" + echo "::set-output name=docker_repo::lnis-uofu" + 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/lnis-uofu/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 @@ -181,7 +192,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to GitHub Container Registry - if: ${{ (github.ref == 'refs/heads/master') || (needs.change_detect.outputs.force_upload == true) }} + if: ${{ (github.ref == 'refs/heads/master' && (env.DOCKER_REPO)) || (needs.change_detect.outputs.force_upload == true) }} uses: docker/login-action@v1 with: registry: ghcr.io @@ -192,15 +203,15 @@ jobs: with: context: . file: ./docker/Dockerfile.master - push: ${{ github.ref == 'refs/heads/master' || needs.change_detect.outputs.force_upload }} + push: ${{ (github.ref == 'refs/heads/master' && (env.DOCKER_REPO)) || needs.change_detect.outputs.force_upload }} tags: | - ghcr.io/lnis-uofu/openfpga-master:latest - ghcr.io/lnis-uofu/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/lnis-uofu/openfpga-env - needs: linux_build + needs: [linux_build, change_detect] + container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-env strategy: fail-fast: false matrix: @@ -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/lnis-uofu/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 bfce9fc79..d1cf27e40 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,13 +1,30 @@ 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 runs-on: ubuntu-latest + if: ${{ secrets.DOCKER_REPO }} 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::$REPO_OWNER" + echo "::set-output name=docker_repo::$REPO_OWNER" + else + echo "name=docker_repo::lnis-uofu" + echo "::set-output name=docker_repo::lnis-uofu" + fi - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -16,7 +33,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 +41,14 @@ jobs: context: . file: ./docker/Dockerfile.base push: true - tags: ghcr.io/lnis-uofu/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/lnis-uofu/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 +74,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 +82,4 @@ jobs: context: . file: ./docker/Dockerfile.${{ matrix.compiler }} push: true - tags: ghcr.io/lnis-uofu/openfpga-build-${{ matrix.compiler }}:latest + tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-${{ matrix.compiler }}:latest