Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Add repo dispatch
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Oswalt <[email protected]>
  • Loading branch information
Mierdin committed Mar 16, 2021
1 parent 8f6813e commit 7e46cf3
Showing 1 changed file with 77 additions and 60 deletions.
137 changes: 77 additions & 60 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,75 +40,92 @@ jobs:

# ----------------------------------------

- name: Create Preview
id: create_preview
run: |
echo ::set-output name=preview_id::$(./create-preview.sh | jq -r '.ID')

- name: Get Buildables
id: get_buildables
- name: Dispatch to other repo
id: preview_dispatch
run: |
echo ::set-output name=buildables::$(cd images && find . -maxdepth 2 -type f -name 'Makefile' -printf '%h;' | tr -d './' | rev | cut -c 2- | rev | jq -Rc 'split(";")')
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action/61236803#61236803
outputs:
preview_id: ${{ steps.create_preview.outputs.preview_id }}
buildables: ${{ steps.get_buildables.outputs.buildables }}

build:
needs: prebuild
runs-on: ubuntu-latest
curl -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/nre-learning/previews/dispatches -d '{"event_type":"preview_image_build"}'
strategy:
matrix:
images_to_build: ${{ fromJson(needs.prebuild.outputs.buildables) }}
steps:
- uses: actions/checkout@v2
- name: Build and push
# VERY IMPORTANT that we statically have "preview-" in the tag name so we don't conflict with existing prod images
# run: "cd images/${{ matrix.images_to_build }} && TARGET_VERSION=preview-$preview_id make docker"
# TODO - remove this and comment back in the "make docker equivalent" above once you're confident that the directory iteration is done properly
# with parallelism
run: "cd images/${{ matrix.images_to_build }} && TARGET_VERSION=preview-$preview_id echo $(pwd)"
env:
preview_id: ${{needs.prebuild.outputs.preview_id}}
retag:
# Some images can't be built automatically, and therefore should just be retagged from a known-good "source" tag, like a curriculum release.
# #///////////////////////

needs: prebuild
runs-on: ubuntu-latest
# - name: Create Preview
# id: create_preview
# run: |
# echo ::set-output name=preview_id::$(./create-preview.sh | jq -r '.ID')

strategy:
matrix:
images_to_retag: [
"vqfx-snap1",
"vqfx-snap2",
"vqfx-snap3",
]
# - name: Get Buildables
# id: get_buildables
# run: |
# echo ::set-output name=buildables::$(cd images && find . -maxdepth 2 -type f -name 'Makefile' -printf '%h;' | tr -d './' | rev | cut -c 2- | rev | jq -Rc 'split(";")')

# # - name: Set up QEMU
# # uses: docker/setup-qemu-action@v1
# # - name: Set up Docker Buildx
# # uses: docker/setup-buildx-action@v1

# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action/61236803#61236803
# outputs:
# preview_id: ${{ steps.create_preview.outputs.preview_id }}
# buildables: ${{ steps.get_buildables.outputs.buildables }}

# build:
# needs: prebuild
# runs-on: ubuntu-latest

# strategy:
# matrix:
# images_to_build: ${{ fromJson(needs.prebuild.outputs.buildables) }}

# steps:
# - uses: actions/checkout@v2
# - name: Build and push
# # VERY IMPORTANT that we statically have "preview-" in the tag name so we don't conflict with existing prod images
# # run: "cd images/${{ matrix.images_to_build }} && TARGET_VERSION=preview-$preview_id make docker"

# # TODO - remove this and comment back in the "make docker equivalent" above once you're confident that the directory iteration is done properly
# # with parallelism
# run: "cd images/${{ matrix.images_to_build }} && TARGET_VERSION=preview-$preview_id echo $(pwd)"

# env:
# preview_id: ${{needs.prebuild.outputs.preview_id}}

# retag:
# # Some images can't be built automatically, and therefore should just be retagged from a known-good "source" tag, like a curriculum release.

# needs: prebuild
# runs-on: ubuntu-latest

# strategy:
# matrix:
# images_to_retag: [
# "vqfx-snap1",
# "vqfx-snap2",
# "vqfx-snap3",
# ]

# steps:
# - uses: actions/checkout@v2
# - name: Build and push
# run: "cd images/${{ matrix.images_to_retag }} && docker pull antidotelabs/${{ matrix.images_to_retag }}:$retag_source && docker tag antidotelabs/${{ matrix.images_to_retag }}:$retag_source antidotelabs/${{ matrix.images_to_retag }}:preview-$preview_id && docker push antidotelabs/${{ matrix.images_to_retag }}:preview-$preview_id"

# env:

# # TODO - this is a weak point, as this may need to get updated every release, if these images change. They often don't, so maybe
# # this is okay for now, and the right thing to do is just fix these images so they can be built properly, at which point
# # this whole job can be deleted.
# retag_source: v1.3.0

steps:
- uses: actions/checkout@v2
- name: Build and push
run: "cd images/${{ matrix.images_to_retag }} && docker tag antidotelabs/${{ matrix.images_to_retag }}:$retag_source antidotelabs/${{ matrix.images_to_retag }}:preview-$preview_id && docker push antidotelabs/${{ matrix.images_to_retag }}:preview-$preview_id"

env:

# TODO - this is a weak point, as this may need to get updated every release, if these images change. They often don't, so maybe
# this is okay for now, and the right thing to do is just fix these images so they can be built properly, at which point
# this whole job can be deleted.
retag_source: v1.3.0
# # 1. Store docker images as tarball
# # 2. From another repo, download these and and push them. This will prevent you from having to build twice

0 comments on commit 7e46cf3

Please sign in to comment.