From 7591be7eef12e1d2361ad26dc375cdc65ce13400 Mon Sep 17 00:00:00 2001 From: AlexandraTrifan Date: Wed, 13 May 2020 18:06:22 +0300 Subject: [PATCH] Github Actions: Create dockerimage.yml and use Github Actions to build a Scopy.flatpak in a clean Docker container. Signed-off-by: AlexandraTrifan --- .github/workflows/dockerimage.yml | 23 +++++++++++++++++++ CI/appveyor/inside_flatpak_docker.sh | 34 +++++++++++++++++++++------- 2 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/dockerimage.yml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml new file mode 100644 index 0000000000..804ced118b --- /dev/null +++ b/.github/workflows/dockerimage.yml @@ -0,0 +1,23 @@ +name: Docker Image CI + +on: [push, pull_request] + +jobs: + + make-flatpak: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Pull the Docker Image + run: docker pull alexandratr/scopy-flatpak-bionic:clean + - name: Run Docker Image + run: | + docker run --privileged \ + -v `pwd`:$GITHUB_WORKSPACE:rw \ + -e "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" \ + alexandratr/scopy-flatpak-bionic:clean /bin/bash -xe $GITHUB_WORKSPACE/CI/appveyor/inside_flatpak_docker.sh + - uses: actions/upload-artifact@v2 + with: + name: Scopy.flatpak + path: ${{ github.workspace }}/Scopy.flatpak diff --git a/CI/appveyor/inside_flatpak_docker.sh b/CI/appveyor/inside_flatpak_docker.sh index 26c0f9dda9..31ff8832a2 100755 --- a/CI/appveyor/inside_flatpak_docker.sh +++ b/CI/appveyor/inside_flatpak_docker.sh @@ -1,8 +1,13 @@ #!/bin/sh -xe +if [ -n "$BRANCH" ]; then + ARTIFACT_LOCATION=/scopy +else + ARTIFACT_LOCATION=$GITHUB_WORKSPACE +fi + apt-get install -y jq -REPO_URL=https://github.com/"$REPO" REPO_LOCAL=/home/docker/scopy-flatpak cd "$REPO_LOCAL" git pull && git checkout master @@ -11,16 +16,29 @@ git pull && git checkout master cnt=$( echo `jq '.modules | length' org.adi.Scopy.json` ) cnt=$(($cnt-1)) -# use jq to replace the Scopy branch + the repo url used for building -# we want to build the branch and repo we're currently on -cat org.adi.Scopy.json | jq --tab '.modules['$cnt'].sources[0].branch = "'$BRANCH'"' > tmp.json -cp tmp.json org.adi.Scopy.json -cat org.adi.Scopy.json | jq --tab '.modules['$cnt'].sources[0].url = "'$REPO_URL'"' > tmp.json +if [ -n "$BRANCH" ]; then + REPO_URL=https://github.com/"$REPO" + # We are building in Appveyor and we have access to the current branch on a CACHED Docker image + # use jq to replace the Scopy branch + the repo url used for building + # we want to build the branch and repo we're currently on + cat org.adi.Scopy.json | jq --tab '.modules['$cnt'].sources[0].branch = "'$BRANCH'"' > tmp.json + cp tmp.json org.adi.Scopy.json + cat org.adi.Scopy.json | jq --tab '.modules['$cnt'].sources[0].url = "'$REPO_URL'"' > tmp.json +else + # We are building in Github Actions and we use the current directory folder on a CLEAN Docker image + cat org.adi.Scopy.json | jq --tab '.modules['$cnt'].sources[0].type = "dir"' > tmp.json + cp tmp.json org.adi.Scopy.json + cat org.adi.Scopy.json | jq --tab '.modules['$cnt'].sources[0].path = "'$GITHUB_WORKSPACE'"' > tmp.json + cp tmp.json org.adi.Scopy.json + cat org.adi.Scopy.json | jq --tab 'del(.modules['$cnt'].sources[0].url)' > tmp.json + cp tmp.json org.adi.Scopy.json + cat org.adi.Scopy.json | jq --tab 'del(.modules['$cnt'].sources[0].branch)' > tmp.json +fi cp tmp.json org.adi.Scopy.json rm tmp.json make clean make -j4 -# Copy the Scopy.flatpak file in /scopy (which is the external location, mount when docker starts) -cp Scopy.flatpak /scopy/ +# Copy the Scopy.flatpak file in $GITHUB_WORKSPACE (which is the external location, mount when docker starts) +cp Scopy.flatpak $ARTIFACT_LOCATION/