diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml new file mode 100644 index 000000000000..a12214c1c81b --- /dev/null +++ b/.github/workflows/docker-push.yml @@ -0,0 +1,72 @@ +name: Tag and push all docker + +on: + workflow_dispatch: {} + push: + tags: + - v* + +env: + CARGO_TERM_COLOR: always + DOCKER_USERNAME: ${{ github.actor }} + +jobs: + build: + name: Build all images + runs-on: ubuntu-20.04 + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + - name: Run make golang-docker + run: | + make golang-docker + + - name: Put all docker images in temp dir + run: | + docker image ls | grep 'us-.*oplabs.*latest' | sed 's/ *latest.*//' | xargs -L1 -I % echo 'docker image save % -o /tmp/%.tar' | sed 's:/tmp/.*/\(.*\.tar\):/tmp/\1:' | bash + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: op-images + path: /tmp/op-*.tar + + push: + name: Tag and push all images + runs-on: ubuntu-20.04 + needs: build + strategy: + matrix: + image: [op-node, op-batcher, op-proposer, op-challenger, op-supervisor, op-dispute-mon] + permissions: + packages: write + contents: read + steps: + - name: Download built artifact + uses: actions/download-artifact@v4 + with: + name: op-images + path: op-images + + - name: Import image + run: | + docker image load --input op-images/${{ matrix.image }}.tar + + - name: Log in to Docker + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin + + - name: Tag image versions + run: | + docker image tag us-docker.pkg.dev/oplabs-tools-artifacts/images/${{ matrix.image }} ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} + + - name: Tag versions + if: ${{ startsWith(github.ref, 'refs/tags/') }} + run: | + docker image tag ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:${{ github.ref_name }} + + - name: Push images + run: | + docker image push -a ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}