Skip to content

Add embed option to polywrap codegen #283

Add embed option to polywrap codegen

Add embed option to polywrap codegen #283

name: CD-Containers
on:
# When Pull Request is merged
pull_request_target:
types: [closed]
jobs:
Publish-Docker-Hub:
name: Publish container images to Docker Hub
if: |
github.event.pull_request.merged &&
endsWith(github.event.pull_request.title, '/workflows/cd-containers') &&
github.event.pull_request.user.login != 'polywrap-build-bot'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Pull-Request Creator Is Publisher?
run: |
exists=$(echo $(grep -Fxcs ${CREATOR} .github/PUBLISHERS))
if [ "$exists" == "1" ] ; then
echo IS_PUBLISHER=true >> $GITHUB_ENV
else
echo IS_PUBLISHER=false >> $GITHUB_ENV
fi
env:
CREATOR: ${{github.event.pull_request.user.login}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: polywrapbuildbot
password: ${{ secrets.POLYWRAP_BUILD_BOT_DOCKERHUB_PAT }}
- name: Cache Image Directories
run: |
echo IMAGE_RS_VM_DIR=./packages/cli/src/lib/defaults/build-strategies/wasm/rust/vm >> $GITHUB_ENV
echo IMAGE_AS_VM_DIR=./packages/cli/src/lib/defaults/build-strategies/wasm/assemblyscript/vm >> $GITHUB_ENV
echo IMAGE_GO_VM_DIR=./packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm >> $GITHUB_ENV
- name: Read Image VERSION & NAME into env.IMAGE_..._VERSION/NAME
run: |
echo IMAGE_RS_VM_NAME=$(cat $IMAGE_RS_VM_DIR/NAME) >> $GITHUB_ENV
echo IMAGE_RS_VM_VERSION=$(cat $IMAGE_RS_VM_DIR/VERSION) >> $GITHUB_ENV
echo IMAGE_AS_VM_NAME=$(cat $IMAGE_AS_VM_DIR/NAME) >> $GITHUB_ENV
echo IMAGE_AS_VM_VERSION=$(cat $IMAGE_AS_VM_DIR/VERSION) >> $GITHUB_ENV
echo IMAGE_GO_VM_NAME=$(cat $IMAGE_GO_VM_DIR/NAME) >> $GITHUB_ENV
echo IMAGE_GO_VM_VERSION=$(cat $IMAGE_GO_VM_DIR/VERSION) >> $GITHUB_ENV
- name: Check if image tags already exist
run: |
echo IMAGE_RS_VM_UNPUBLISHED=$(! curl -s "https://hub.docker.com/v2/repositories/$IMAGE_RS_VM_NAME/tags/$IMAGE_RS_VM_VERSION" | grep -q "error 404" > /dev/null ; echo $?) >> $GITHUB_ENV
echo IMAGE_AS_VM_UNPUBLISHED=$(! curl -s "https://hub.docker.com/v2/repositories/$IMAGE_AS_VM_NAME/tags/$IMAGE_AS_VM_VERSION" | grep -q "error 404" > /dev/null ; echo $?) >> $GITHUB_ENV
echo IMAGE_GO_VM_UNPUBLISHED=$(! curl -s "https://hub.docker.com/v2/repositories/$IMAGE_GO_VM_NAME/tags/$IMAGE_GO_VM_VERSION" | grep -q "error 404" > /dev/null ; echo $?) >> $GITHUB_ENV
- name: Build & Publish RS VM Image
if: env.IMAGE_RS_VM_UNPUBLISHED == '1'
working-directory: ${{env.IMAGE_RS_VM_DIR}}
run: |
docker buildx create --use --name rs-vm-builder
docker buildx build . --platform=linux/amd64,linux/arm64 -t $IMAGE_RS_VM_NAME:latest -t $IMAGE_RS_VM_NAME:$IMAGE_RS_VM_VERSION --output type=registry
docker buildx rm rs-vm-builder
- name: Build & Publish AS VM Image
if: env.IMAGE_AS_VM_UNPUBLISHED == '1'
working-directory: ${{env.IMAGE_AS_VM_DIR}}
run: |
docker buildx create --use --name as-vm-builder
docker buildx build . --platform=linux/amd64,linux/arm64 -t $IMAGE_AS_VM_NAME:latest -t $IMAGE_AS_VM_NAME:$IMAGE_AS_VM_VERSION --output type=registry
docker buildx rm as-vm-builder
- name: Build & Publish GO VM Image
if: env.IMAGE_GO_VM_UNPUBLISHED == '1'
working-directory: ${{env.IMAGE_GO_VM_DIR}}
run: |
docker buildx create --use --name go-vm-builder
docker buildx build . --platform=linux/amd64,linux/arm64 -t $IMAGE_GO_VM_NAME:latest -t $IMAGE_GO_VM_NAME:$IMAGE_GO_VM_VERSION --output type=registry
docker buildx rm go-vm-builder