Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Saved docker as release artifact
Browse files Browse the repository at this point in the history
- Create an action for uploading to release
- The release and tag will be created before this is run
- Use the shell script to create the docker image from sources
  -> Save the image and gzip it
  -> Upload it to created release
  • Loading branch information
djova-dolby committed Sep 4, 2023
1 parent e177730 commit d9d6f20
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 10 deletions.
51 changes: 51 additions & 0 deletions .github/actions/upload-assets/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

function show_help() {
echo " Usage:"
echo " bash ${PATH_TO_DIR}/upload.sh [--repo_name REPONAME] [--file_name FILENAME]"
echo
echo " --reponame Name of repo to upload too."
echo " --filename Name of file to upload."
echo " -h|--help Print this help."
}

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--reponame)
REPONAME="$2"
shift
shift
;;
--filename)
FILENAME="$2"
shift
shift
;;
-h|--help)
show_help
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done

ID_OF_RELEASE=$(curl --fail -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/DolbyIO/${REPONAME}/releases/tags/${GITHUB_REF_NAME} | jq ".id")

echo "uploading file ${FILENAME} for tag: ${GITHUB_REF_NAME} for ID: ${ID_OF_RELEASE}"

curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/gzip" \
https://uploads.github.com/repos/DolbyIO/${REPONAME}/releases/${ID_OF_RELEASE}/assets?name=${1}\
--data-binary "@${FILENAME}"
38 changes: 35 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build RTME

env:
DOCKER_HUB_REPO: "voxeet/real-time-media-extensions"
DOCKER_HUB_REPO: "dolbyio/real-time-media-extensions"

on:
pull_request:
Expand Down Expand Up @@ -48,9 +48,10 @@ jobs:
name: docker-resource
path: docker-resource.zip
retention-days: 1


# Disable this job for now until repo is set
build-deploy-docker:
if: github.ref_type == 'tag'
if: false
runs-on: ubuntu-20.04
needs: build-resources
steps:
Expand Down Expand Up @@ -87,3 +88,34 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build-save-docker:
if: github.ref_type == 'tag'
runs-on: ubuntu-20.04
needs: build-resources
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Download docker resources
uses: actions/download-artifact@v3
with:
name: docker-resource

- name: Build and release docker
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
unzip docker-resource.zip && rm docker-resource.zip
sudo bash setup/linux.sh --build_docker ${{ env.DOCKER_HUB_REPO }} ${GITHUB_REF_NAME} --skip_building
ls -l
sudo chmod 777 dolbyio_rtme-${GITHUB_REF_NAME}.tar.gz
gh release upload ${GITHUB_REF_NAME} dolbyio_rtme-${GITHUB_REF_NAME}.tar.gz
#sudo bash .github/actions/upload-assets/upload.sh --filename dolbyio_rtme-${GITHUB_REF_NAME}.tar.gz --reponame real-time-media-extensions
- name: Upload docker package
uses: actions/upload-artifact@v3
with:
name: docker-rtme-image
path: dolbyio_rtme-${GITHUB_REF_NAME}.tar.gz
retention-days: 7
15 changes: 8 additions & 7 deletions setup/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ prepare_docker_image() {
}

build_docker_image() {
docker_repo=${1}
docker_tag=${2}
pushd ${WORK_DIR}
docker build -t ${docker_repo}:${docker_tag} -f Dockerfile --no-cache .
docker save --output dolbyio_rtme-${docker_tag}.tar ${docker_repo}:${docker_tag}
gzip -9 dolbyio_rtme-${docker_tag}.tar
popd
docker_repo=${1}
docker_tag=${2}
pushd ${WORK_DIR}
docker build -t ${docker_repo}:${docker_tag} -f Dockerfile --no-cache .
docker save --output dolbyio_rtme-${docker_tag}.tar ${docker_repo}:${docker_tag}
gzip -9 dolbyio_rtme-${docker_tag}.tar
ls -l
popd
}

0 comments on commit d9d6f20

Please sign in to comment.