Corrected docker CI pipeline

This commit is contained in:
Tom Foster 2024-04-22 11:54:24 +01:00
parent be3483ed38
commit 4889fca712

View file

@ -92,20 +92,18 @@ jobs:
run: | run: |
./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation ./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation
- name: Perform continuous integration - name: Perform continuous integration
run: direnv exec . engage run: direnv exec . engage
build-static: build-static:
name: Static Artifacts name: Static Artifacts
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: tests needs: tests
strategy: strategy:
max-parallel: 3 max-parallel: 8
matrix: matrix:
target: [ target:
[
"x86_64-unknown-linux-musl", "x86_64-unknown-linux-musl",
"x86_64-unknown-linux-musl-jemalloc", "x86_64-unknown-linux-musl-jemalloc",
"aarch64-unknown-linux-musl", "aarch64-unknown-linux-musl",
@ -174,7 +172,6 @@ jobs:
run: | run: |
./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation ./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation
- name: Build static artifacts - name: Build static artifacts
run: | run: |
./bin/nix-build-and-cache .#static-${{ matrix.target }} ./bin/nix-build-and-cache .#static-${{ matrix.target }}
@ -196,17 +193,15 @@ jobs:
path: target/debian/${{ matrix.target }}.deb path: target/debian/${{ matrix.target }}.deb
if-no-files-found: error if-no-files-found: error
build-oci: build-oci:
name: OCI Artifacts and Publish name: OCI Artifacts and Publish
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: tests needs: tests
strategy: strategy:
max-parallel: 3 max-parallel: 8
matrix: matrix:
oci-target: [ oci-target:
#"x86_64-unknown-linux-gnu", [
"x86_64-unknown-linux-musl", "x86_64-unknown-linux-musl",
"x86_64-unknown-linux-musl-jemalloc", "x86_64-unknown-linux-musl-jemalloc",
"aarch64-unknown-linux-musl", "aarch64-unknown-linux-musl",
@ -275,7 +270,6 @@ jobs:
run: | run: |
./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation ./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation
- name: Build OCI images - name: Build OCI images
run: | run: |
./bin/nix-build-and-cache .#oci-image-${{ matrix.oci-target }} ./bin/nix-build-and-cache .#oci-image-${{ matrix.oci-target }}
@ -296,11 +290,17 @@ jobs:
needs: build-oci needs: build-oci
steps: steps:
- name: Login to Docker Hub - name: Download OCI Images Artifacts
uses: docker/login-action@v3 uses: actions/download-artifact@v4
with: with:
username: ${{ secrets.DOCKER_USERNAME }} merge-multiple: true
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Load OCI Images and tag
run: |
ID_AARCH64=$(docker load -i oci-image-aarch64-unknown-linux-musl-jemalloc.tar.gz | sed -n 's/Loaded image: \(.*\)/\1/p')
docker tag $ID_AARCH64 conduwuit:${{ github.sha }}-aarch64-jemalloc
ID_X86_64=$(docker load -i oci-image-x86_64-unknown-linux-musl-jemalloc.tar.gz | sed -n 's/Loaded image: \(.*\)/\1/p')
docker tag $ID_X86_64 conduwuit:${{ github.sha }}-x86_64-jemalloc
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -309,53 +309,46 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Load OCI Images - name: Create and push Manifest to GitHub
run: | run: |
docker load -i oci-image-x86_64-unknown-linux-musl-jemalloc.tar.gz REPO_GHCR="ghcr.io/${{ github.repository }}"
docker load -i oci-image-aarch64-unknown-linux-musl-jemalloc.tar.gz SHA_TAG="${{ github.ref_name }}-${{ github.sha }}"
BRANCH_TAG="${{ github.ref_name }}"
- name: Create and Push Manifest to Docker Hub if [ "$BRANCH_TAG" == "main" ]; then
run: |
DOCKER_IMAGE_NAME="docker.io/${{ github.repository }}"
BRANCH_NAME="${{ github.ref_name }}"
SHA_TAG="${BRANCH_NAME}-${{ github.sha }}"
BRANCH_TAG=$BRANCH_NAME
if [ "$BRANCH_NAME" == "main" ]; then
BRANCH_TAG="latest" BRANCH_TAG="latest"
fi fi
# Create and push SHA specific manifest docker manifest create $REPO_GHCR:$SHA_TAG \
docker manifest create $DOCKER_IMAGE_NAME:$SHA_TAG \ --amend conduwuit:${{ github.sha }}-x86_64-jemalloc \
--amend $DOCKER_IMAGE_NAME:${{ github.sha }}-x86_64-jemalloc \ --amend conduwuit:${{ github.sha }}-aarch64-jemalloc
--amend $DOCKER_IMAGE_NAME:${{ github.sha }}-aarch64-jemalloc docker manifest push $REPO_GHCR:$SHA_TAG
docker manifest push $DOCKER_IMAGE_NAME:$SHA_TAG
# Update and push branch or latest manifest docker manifest create $REPO_GHCR:$BRANCH_TAG \
docker manifest create $DOCKER_IMAGE_NAME:$BRANCH_TAG \ --amend conduwuit:${{ github.sha }}-x86_64-jemalloc \
--amend $DOCKER_IMAGE_NAME:${{ github.sha }}-x86_64-jemalloc \ --amend conduwuit:${{ github.sha }}-aarch64-jemalloc
--amend $DOCKER_IMAGE_NAME:${{ github.sha }}-aarch64-jemalloc docker manifest push $REPO_GHCR:$BRANCH_TAG
docker manifest push $DOCKER_IMAGE_NAME:$BRANCH_TAG
- name: Create and Push Manifest to GitHub Container Registry - name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push manifest to Docker Hub
run: | run: |
GHCR_IMAGE_NAME="ghcr.io/${{ github.repository }}" REPO_DOCKER="docker.io/${{ github.repository }}"
BRANCH_NAME="${{ github.ref_name }}" SHA_TAG="${{ github.ref_name }}-${{ github.sha }}"
SHA_TAG="${BRANCH_NAME}-${{ github.sha }}" BRANCH_TAG="${{ github.ref_name }}"
BRANCH_TAG=$BRANCH_NAME if [ "$BRANCH_TAG" == "main" ]; then
if [ "$BRANCH_NAME" == "main" ]; then
BRANCH_TAG="latest" BRANCH_TAG="latest"
fi fi
# Create and push SHA specific manifest docker manifest create $REPO_DOCKER:$SHA_TAG \
docker manifest create $GHCR_IMAGE_NAME:$SHA_TAG \ --amend conduwuit:${{ github.sha }}-x86_64-jemalloc \
--amend $GHCR_IMAGE_NAME:${{ github.sha }}-x86_64-jemalloc \ --amend conduwuit:${{ github.sha }}-aarch64-jemalloc
--amend $GHCR_IMAGE_NAME:${{ github.sha }}-aarch64-jemalloc docker manifest push $REPO_DOCKER:$SHA_TAG
docker manifest push $GHCR_IMAGE_NAME:$SHA_TAG
# Update and push branch or latest manifest docker manifest create $REPO_DOCKER:$BRANCH_TAG \
docker manifest create $GHCR_IMAGE_NAME:$BRANCH_TAG \ --amend conduwuit:${{ github.sha }}-x86_64-jemalloc \
--amend $GHCR_IMAGE_NAME:${{ github.sha }}-x86_64-jemalloc \ --amend conduwuit:${{ github.sha }}-aarch64-jemalloc
--amend $GHCR_IMAGE_NAME:${{ github.sha }}-aarch64-jemalloc docker manifest push $REPO_DOCKER:$BRANCH_TAG
docker manifest push $GHCR_IMAGE_NAME:$BRANCH_TAG