From 626806229fca1bac67ad130bf93a2704409059af Mon Sep 17 00:00:00 2001 From: Lydia Ross Date: Wed, 29 Mar 2023 16:42:05 +0100 Subject: [PATCH 1/2] ci: Add GHA workflow for creating docker image --- .github/workflows/docker-image-on-release.yml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/docker-image-on-release.yml diff --git a/.github/workflows/docker-image-on-release.yml b/.github/workflows/docker-image-on-release.yml new file mode 100644 index 000000000..94c2c4c52 --- /dev/null +++ b/.github/workflows/docker-image-on-release.yml @@ -0,0 +1,62 @@ +name: Docker Image CI + +on: + release: + types: [published] + +env: + IMAGE_NAME: learninglocker/xapi-service + +jobs: + main: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'yarn' + + - name: Installing Dependencies + run: yarn install --ignore-engines --frozen-lockfile + + - name: Compiling Code + run: yarn build + + - name: Determine version + id: version + run: | + # Strip git ref prefix from version + version=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && version=$(echo $version | sed -e 's/^v//') + echo "::set-output name=version::$version" + + - 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 }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} + build-args: | + GIT_COMMIT=${{ github.sha }} + VERSION=${{ steps.version.outputs.version }} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From 96cab12e32a47dab96cab57f3f8e8583305e7d19 Mon Sep 17 00:00:00 2001 From: Lydia Ross Date: Fri, 21 Apr 2023 11:22:00 +0100 Subject: [PATCH 2/2] ci: Remove set-output --- .github/workflows/docker-image-on-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image-on-release.yml b/.github/workflows/docker-image-on-release.yml index 94c2c4c52..97be9537e 100644 --- a/.github/workflows/docker-image-on-release.yml +++ b/.github/workflows/docker-image-on-release.yml @@ -32,7 +32,7 @@ jobs: version=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # Strip "v" prefix from tag name [[ "${{ github.ref }}" == "refs/tags/"* ]] && version=$(echo $version | sed -e 's/^v//') - echo "::set-output name=version::$version" + echo "version=$version" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@v1