diff --git a/.github/workflows/build-job.yaml b/.github/workflows/build-job.yaml index 0d9792a..030c306 100644 --- a/.github/workflows/build-job.yaml +++ b/.github/workflows/build-job.yaml @@ -62,6 +62,8 @@ jobs: platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/386 push: true tags: ${{ inputs.tags }} + build-args: VERSION=${{ inputs.image-version }} + # TODO github.event.created_at does not seem to work labels: | org.opencontainers.image.created=${{ github.event.created_at }} org.opencontainers.image.url=https://hub.docker.com/r/ckulka/baikal diff --git a/.github/workflows/test-job.yaml b/.github/workflows/test-job.yaml index 47a00db..31b6dd0 100644 --- a/.github/workflows/test-job.yaml +++ b/.github/workflows/test-job.yaml @@ -16,6 +16,17 @@ jobs: test: runs-on: ubuntu-latest steps: + # Get the latest release version from the GitHub API + - name: Parse release tag + id: parse-release-tag + run: | + echo Parsing tag from latest release ref $REF_NAME + REF_NAME=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') + echo Latest release ref is $REF_NAME + BAIKAL_VERSION=${REF_NAME/+*/} + echo Parsed Baikal version $BAIKAL_VERSION from release $REF_NAME + echo BAIKAL_VERSION=$BAIKAL_VERSION >> "$GITHUB_OUTPUT" + - uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} @@ -31,13 +42,20 @@ jobs: - name: Build Docker image id: build - run: docker build -f ${{ inputs.dockerfile }}.dockerfile -t baikal-image . + run: > + docker build + --file ${{ inputs.dockerfile }}.dockerfile + --build-arg VERSION=${{ steps.parse-release-tag.outputs.BAIKAL_VERSION }} + --tag baikal-image + . - name: Start Baikal container run: docker run --rm -dp 80:80 --name ${{ inputs.dockerfile }} baikal-image - name: Run Cypress tests run: npm run test + env: + CYPRESS_BAIKAL_VERSION: ${{ steps.parse-release-tag.outputs.BAIKAL_VERSION }} - name: Stop Baikal container run: docker stop ${{ inputs.dockerfile }} @@ -59,7 +77,10 @@ jobs: docker cp ${{ github.workspace }}/cypress/fixtures/mail-test.php baikal:/var/www/baikal/html/ - name: Run Cypress tests incl. MSMTP - run: CYPRESS_MSMTP_ENABLED=TRUE npm run test + run: npm run test + env: + CYPRESS_MSMTP_ENABLED: TRUE + CYPRESS_BAIKAL_VERSION: ${{ steps.parse-release-tag.outputs.BAIKAL_VERSION }} - name: Archive test results if: always() diff --git a/apache-php8.2.dockerfile b/apache-php8.2.dockerfile index a9e09c9..c32d5e9 100644 --- a/apache-php8.2.dockerfile +++ b/apache-php8.2.dockerfile @@ -1,7 +1,7 @@ # Multi-stage build, see https://docs.docker.com/develop/develop-images/multistage-build/ FROM alpine AS builder -ENV VERSION 0.9.5 +ARG VERSION ADD https://github.com/sabre-io/Baikal/releases/download/$VERSION/baikal-$VERSION.zip . RUN apk add unzip && unzip -q baikal-$VERSION.zip diff --git a/apache.dockerfile b/apache.dockerfile index da35940..1e3c80f 100644 --- a/apache.dockerfile +++ b/apache.dockerfile @@ -1,7 +1,7 @@ # Multi-stage build, see https://docs.docker.com/develop/develop-images/multistage-build/ FROM alpine AS builder -ENV VERSION 0.9.5 +ARG VERSION ADD https://github.com/sabre-io/Baikal/releases/download/$VERSION/baikal-$VERSION.zip . RUN apk add unzip && unzip -q baikal-$VERSION.zip diff --git a/cypress/e2e/create-baikal-instance.cy.ts b/cypress/e2e/create-baikal-instance.cy.ts index 77eb844..015a088 100644 --- a/cypress/e2e/create-baikal-instance.cy.ts +++ b/cypress/e2e/create-baikal-instance.cy.ts @@ -9,6 +9,12 @@ describe("Create Baikal instance", () => { "Baïkal initialization wizard", ); + // Assert the correct Baikal version was installed + cy.get("#overview > p.lead").should( + "have.text", + `Configure your new Baïkal ${Cypress.env("BAIKAL_VERSION")} installation.`, + ); + // Set administrator credentials cy.get("#admin_passwordhash").type(adminCredentials); cy.get("#admin_passwordhash_confirm").type(adminCredentials); diff --git a/nginx-php8.2.dockerfile b/nginx-php8.2.dockerfile index 297ba43..123b898 100644 --- a/nginx-php8.2.dockerfile +++ b/nginx-php8.2.dockerfile @@ -1,7 +1,7 @@ # Multi-stage build, see https://docs.docker.com/develop/develop-images/multistage-build/ FROM alpine AS builder -ENV VERSION 0.9.5 +ARG VERSION ADD https://github.com/sabre-io/Baikal/releases/download/$VERSION/baikal-$VERSION.zip . RUN apk add unzip && unzip -q baikal-$VERSION.zip diff --git a/nginx.dockerfile b/nginx.dockerfile index 10bc943..70271d8 100644 --- a/nginx.dockerfile +++ b/nginx.dockerfile @@ -1,7 +1,7 @@ # Multi-stage build, see https://docs.docker.com/develop/develop-images/multistage-build/ FROM alpine AS builder -ENV VERSION 0.9.5 +ARG VERSION ADD https://github.com/sabre-io/Baikal/releases/download/$VERSION/baikal-$VERSION.zip . RUN apk add unzip && unzip -q baikal-$VERSION.zip