diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml new file mode 100644 index 0000000..a385df7 --- /dev/null +++ b/.github/workflows/on-pull-request.yml @@ -0,0 +1,50 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images + +name: Publish Test Docker Image + +on: + pull_request: + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: carlpaton/redis-administrator:test + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: index.docker.io/carlpaton/redis-administrator + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/.github/workflows/docker-image.yml b/.github/workflows/on-push.yml similarity index 93% rename from .github/workflows/docker-image.yml rename to .github/workflows/on-push.yml index 5599009..998e2ab 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/on-push.yml @@ -9,10 +9,9 @@ # https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images -name: Publish Docker image +name: Publish Latest Docker Image on: - workflow_dispatch: push: branches: - 'master' @@ -43,7 +42,7 @@ jobs: context: . file: ./Dockerfile push: true - tags: carlpaton/redis-administrator:develop + tags: carlpaton/redis-administrator:latest - name: Generate artifact attestation uses: actions/attest-build-provenance@v2 diff --git a/Common/Common.csproj b/Common/Common.csproj index ea83d29..cb63190 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 diff --git a/Dockerfile b/Dockerfile index 3576aa6..702225d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use the SDK image for the build stage -FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env WORKDIR /app # Copy csproj files and restore as distinct layers @@ -19,7 +19,7 @@ RUN dotnet publish ./WebApp/WebApp.csproj -c Release -o out # RUN dotnet test "./IntegrationTests/IntegrationTests.csproj" -c Release --no-build --no-restore # Build runtime image -FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 WORKDIR /app # Copy the published output from the build-env stage COPY --from=build-env /app/out ./ diff --git a/IntegrationTests/IntegrationTests.csproj b/IntegrationTests/IntegrationTests.csproj index 6409e18..a262334 100644 --- a/IntegrationTests/IntegrationTests.csproj +++ b/IntegrationTests/IntegrationTests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 false diff --git a/README.md b/README.md index 7e39cfd..dd52436 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ docker run --name red-admin -d -p 8081:80 --env REDIS_CONNECTION=red-srv,allowAd Pull requests welcome! - [Local Setup](./docs/local-setup.md) +- [Redis Types](https://carlpaton.github.io/2022/02/redis-types/) ## Developers diff --git a/RedisRepository/RedisRepository.csproj b/RedisRepository/RedisRepository.csproj index 578dd73..dcea9fd 100644 --- a/RedisRepository/RedisRepository.csproj +++ b/RedisRepository/RedisRepository.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 diff --git a/WebApp/Views/Shared/_Layout.cshtml b/WebApp/Views/Shared/_Layout.cshtml index eae475f..3d80234 100644 --- a/WebApp/Views/Shared/_Layout.cshtml +++ b/WebApp/Views/Shared/_Layout.cshtml @@ -79,7 +79,7 @@ © @DateTime.Now.ToString("yyyy") - Redis Administrator is powered by Bootstrap , StackExchange.Redis - and .Net 3.0 + and .Net 3.1 diff --git a/WebApp/WebApp.csproj b/WebApp/WebApp.csproj index 63a1649..b536c3c 100644 --- a/WebApp/WebApp.csproj +++ b/WebApp/WebApp.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 diff --git a/docs/local-setup.md b/docs/local-setup.md index bec622e..dbd8b47 100644 --- a/docs/local-setup.md +++ b/docs/local-setup.md @@ -3,7 +3,7 @@ ## Prerequisites Install the following -1. [.Net SDK 3](https://dotnet.microsoft.com/en-us/download/dotnet/3.0) +1. [.Net SDK 3.1](https://dotnet.microsoft.com/en-us/download/dotnet/3.1) 1. libman with `dotnet tool install -g Microsoft.Web.LibraryManager.Cli` 1. [docker desktop](https://www.docker.com/products/docker-desktop/) @@ -21,24 +21,24 @@ Currently no unit tests exist 🐒, also dafuc is [MS Test](https://carlpaton.gi 1. `cd .\IntegrationTests\` 1. run `dotnet test` -## Deploy Docker Registry -This deploys to https://hub.docker.com/ +## Manual Deploy Docker Registry +This deploys to https://hub.docker.com/, merging to master also triggers [this action](https://github.com/carlpaton/RedisAdministrator/actions) which publishes [latest tag](https://hub.docker.com/r/carlpaton/redis-administrator/tags). I last did this with an integration from Github to Docker.com but they have since canned this feature and put it behind a paywall, I'll update here after I figure out how to do it. -1. build image with `docker build -t redis-administrator:dev .` -1. run it locally as `docker run --name red-admin-dev -d -p 8082:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true redis-administrator:dev` +1. build image with `docker build -t redis-administrator:develop .` +1. run it locally as `docker run --name red-admin-develop -d -p 8082:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true redis-administrator:develop` 1. browse to http://localhost:8082 Now actually deploy 1. `docker login`, one time device confirmation opens docker.com for you to confirm -1. tag the image `docker tag redis-administrator:dev carlpaton/redis-administrator:dev` -1. now push `docker push carlpaton/redis-administrator:dev` +1. tag the image `docker tag redis-administrator:develop carlpaton/redis-administrator:develop` +1. now push `docker push carlpaton/redis-administrator:develop` 1. browse and check the tag exists at https://hub.docker.com/r/carlpaton/redis-administrator/ Test the deployed image -1. delete local image tagged as `carlpaton/redis-administrator:dev` -1. run locally as `docker run --name red-admin-deploy -d -p 8083:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true carlpaton/redis-administrator:dev` which should then pull from docker hub +1. delete local image tagged as `carlpaton/redis-administrator:develop` +1. run locally as `docker run --name red-admin-deploy -d -p 8083:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true carlpaton/redis-administrator:develop` which should then pull from docker hub 1. browse to http://localhost:8083 \ No newline at end of file