Skip to content

Commit

Permalink
ci: Add building the docker image for Box to the build (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Mar 4, 2023
1 parent d446b94 commit 9d6240f
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ jobs:
name: Publish the Docker image
needs:
- build-phar
if: github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: box-phar
Expand All @@ -124,10 +126,10 @@ jobs:
# See https://github.com/actions/download-artifact#limitations
# the permissions are not guaranteed to be preserved
- name: Ensure PHAR is executable
run: chmod 755 box.phar

- name: Check that the PHAR works
run: ./box.phar --ansi --version
run: |
chmod 755 box.phar
mv -vf box.phar bin/box.phar
./bin/box.phar --ansi --version
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -136,32 +138,53 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to Docker Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup the Docker (release) tag(s)
if: github.event_name == 'release'
run: |
echo "DOCKER_TAGS<<$EOF" >> $GITHUB_ENV
${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }} >> $GITHUB_ENV
${{ env.DOCKERHUB_USERNAME }}/box:latest >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
echo "DOCKER_TEST_TAG=${{ env.DOCKERHUB_USERNAME }}/box:latest" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
if: github.event_name != 'release'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup the Docker tag(s)
if: github.event_name != 'release'
run: |
echo "DOCKER_TAGS=ghcr.io/box-project/box" >> $GITHUB_ENV
echo "DOCKER_TEST_TAG=ghcr.io/box-project/box" >> $GITHUB_ENV
- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
tags: |
${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }}
${{ env.DOCKERHUB_USERNAME }}/box:latest
tags: ${{ env.DOCKER_TAGS }}
load: true

- name: Test the image
run: docker run --rm ${{ env.DOCKERHUB_USERNAME }}/box:latest --version
- name: Test the (release) image
run: docker run --rm ${{ env.DOCKER_TEST_TAG }} --version

- name: Build and push
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
context: .
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
tags: |
${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }}
${{ env.DOCKERHUB_USERNAME }}/box:latest
tags: ${{ env.DOCKER_TAGS }}
push: true

0 comments on commit 9d6240f

Please sign in to comment.