Build Nushell Nightly Image @ Alpine #437
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@v6 | |
| 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} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| let header = [Authorization $'Bearer ($env.GITHUB_TOKEN)'] | |
| let queryApi = http get -H $header https://api.github.com/repos/nushell/nightly/releases | |
| | sort-by -r created_at | where name =~ nightly | 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@v6 | |
| with: | |
| owner_type: user | |
| untagged_only: true | |
| package_name: 'nushell' | |
| repository_owner: 'nushell' | |
| repository: 'nushell/nushell' | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| except_untagged_multiplatform: true |