diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62f0f1a..1522daf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,13 +3,13 @@ name: build on: workflow_call: inputs: - push: + deploy: type: boolean default: false workflow_dispatch: inputs: - push: + deploy: type: boolean default: false @@ -17,26 +17,29 @@ jobs: build: runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: - name: Checkout - uses: actions/checkout@v4.2.2 + uses: actions/checkout@v6.0.2 - name: Set up QEMU - uses: docker/setup-qemu-action@v3.6.0 + uses: docker/setup-qemu-action@v4.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.11.1 + uses: docker/setup-buildx-action@v4.0.0 - name: Log in to Docker Hub - if: ${{ inputs.push }} - uses: docker/login-action@v3.4.0 + uses: docker/login-action@v4.0.0 with: username: ${{ secrets.DOCKERHUB_USER }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract Docker metadata id: meta - uses: docker/metadata-action@v5.7.0 + uses: docker/metadata-action@v6.0.0 with: images: ${{ secrets.DOCKERHUB_USER }}/join-ci tags: | @@ -44,11 +47,13 @@ jobs: type=sha type=raw,value=latest,enable={{is_default_branch}} - - name: Build and push Docker image - uses: docker/build-push-action@v6.18.0 + - name: Build and Deploy Docker image + uses: docker/build-push-action@v7.0.0 with: context: . - push: ${{ inputs.push }} + push: ${{ inputs.deploy }} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USER }}/join-ci:buildcache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USER }}/join-ci:buildcache,mode=max diff --git a/.github/workflows/push.yml b/.github/workflows/cd.yml similarity index 64% rename from .github/workflows/push.yml rename to .github/workflows/cd.yml index 696267f..e1033b6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/cd.yml @@ -1,12 +1,16 @@ -name: image +name: cd on: push: branches: [ main ] + workflow_dispatch: + jobs: - push: + deploy: uses: ./.github/workflows/build.yml + secrets: inherit + with: - push: true + deploy: true diff --git a/.github/workflows/test.yml b/.github/workflows/ci.yml similarity index 71% rename from .github/workflows/test.yml rename to .github/workflows/ci.yml index fee0ef4..02aac4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,13 @@ -name: pr +name: ci on: pull_request: branches: [ main ] + workflow_dispatch: + jobs: - test: + check: uses: ./.github/workflows/build.yml + secrets: inherit - with: - push: false diff --git a/Dockerfile b/Dockerfile index 59779be..370e238 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,8 @@ RUN apt-get update && bash -xe ./01*.sh && rm -rf * && rm -rf /var/lib/apt/lists COPY scripts/02*.sh . RUN apt-get update && bash -xe ./02*.sh && rm -rf * && rm -rf /var/lib/apt/lists/* +USER root +ENV HOME=/root WORKDIR /github/workspace CMD ["/bin/bash"] diff --git a/README.md b/README.md index 2e9d710..77b7bee 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,12 @@ This is an Ubuntu based docker image, with all the mandatory tools for the join To create the docker image do this: ```bash -docker build -t joinframework/join-ci . +docker buildx build --platform linux/amd64,linux/arm64 -t joinframework/join-ci . +``` + +To create and test locally for a single platform do this: +```bash +docker buildx build --platform linux/amd64 --load -t joinframework/join-ci . ``` ## Testing image diff --git a/scripts/01_install_dependencies.sh b/scripts/01_install_dependencies.sh index f806655..e50560d 100644 --- a/scripts/01_install_dependencies.sh +++ b/scripts/01_install_dependencies.sh @@ -20,13 +20,12 @@ apt-get -qq install \ clang \ llvm \ ninja-build \ - wget \ python3 \ python3-pip \ bash \ jq \ libc6-dev \ - libglib2.0-0 \ + libglib2.0-dev \ libtrace-tools \ lcov \ libclang-rt-dev \ diff --git a/scripts/02_install_hugo.sh b/scripts/02_install_hugo.sh index 8245686..8427e4a 100644 --- a/scripts/02_install_hugo.sh +++ b/scripts/02_install_hugo.sh @@ -13,6 +13,8 @@ else fi wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz -tar -xvzf hugo_extended_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz +wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_checksums.txt +grep "hugo_extended_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz" hugo_${HUGO_VERSION}_checksums.txt | sha256sum -c - +tar -xzf hugo_extended_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz mv hugo /usr/local/bin/ -rm hugo_extended_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz LICENSE README.md +rm hugo_extended_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz hugo_${HUGO_VERSION}_checksums.txt LICENSE README.md