Skip to content

Build Nushell Nightly Image @ Alpine #83

Build Nushell Nightly Image @ Alpine

Build Nushell Nightly Image @ Alpine #83

name: Build Nushell Nightly Image @ Alpine
on:
push:
branches:
- main
paths:
- docker/Dockerfile
schedule:
- cron: '0 5 * * *' # run at 05:00 AM UTC
workflow_dispatch:
jobs:
build-and-push-Nu:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: main
- name: Set up Nushell
uses: hustcer/setup-nu@v3
with:
check-latest: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Set tag & labels for ${{ github.ref }}"
shell: nu {0}
run: |
let queryApi = http get https://api.github.com/repos/nushell/nightly/releases
| sort-by -r created_at | get 0.url
$'NU_VERSION=nightly(char nl)' o>> $env.GITHUB_ENV
$'RELEASE_QUERY_API=($queryApi)(char nl)' o>> $env.GITHUB_ENV
$'BUILD_REF=(git rev-parse --short HEAD)(char nl)' o>> $env.GITHUB_ENV
$'BUILD_DATE=(date now | format date %Y-%m-%dT%H:%M:%SZ)(char nl)' o>> $env.GITHUB_ENV
- name: Build Alpine Test Image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
push: false
load: true
context: ./docker
file: ./docker/Dockerfile
tags: nushell-test-image
- name: Test Alpine Image
run: |
echo "## Alpine Container Test Results" >> $GITHUB_STEP_SUMMARY
docker run --rm \
-v "$(pwd)/docker:/work" \
--env GITHUB_ACTIONS=${{ env.GITHUB_ACTIONS }} \
nushell-test-image -c /work/test_docker.nu \
>> $GITHUB_STEP_SUMMARY
- name: Build and Push Alpine Image
uses: docker/build-push-action@v6
with:
push: true
provenance: false
context: ./docker
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_REF=${{ env.BUILD_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
NU_VERSION=${{ env.NU_VERSION }}
RELEASE_QUERY_API=${{ env.RELEASE_QUERY_API }}
tags: |
ghcr.io/nushell/nushell:${{ env.NU_VERSION }}
cleanup:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: build-and-push-Nu
steps:
- name: Delete all containers from repository without tags
uses: Chizkiyahu/delete-untagged-ghcr-action@v4
with:
owner_type: user
untagged_only: true
package_name: 'nushell'
repository_owner: 'nushell'
repository: 'nushell/nushell'
token: ${{ secrets.GITHUB_TOKEN }}
except_untagged_multiplatform: true