Skip to content

Commit

Permalink
Inject LBHPACKAGESTOKEN with GITHUB_TOKEN for CI runs
Browse files Browse the repository at this point in the history
GitHub Actions exposes a `GITHUB_TOKEN` secret which allows installing
and publishing packages. Developers are used to using `LBHPACKAGESTOKEN`
locally, so this change only updates GitHub Actions to correctly inject
the `GITHUB_TOKEN`.

This will allow us to remove the shared secrets in GitHub Actions:

- `NUGET_KEY`
- `LBHPACKAGESTOKEN`

At the same time, this doesn't affect the local development
workflow.
  • Loading branch information
spikeheap committed Oct 1, 2024
1 parent ba15add commit c934062
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
calculate-version:
name: Calculate Version
runs-on: ubuntu-latest
env:
LBHPACKAGESTOKEN: ${{ secrets.LBHPACKAGESTOKEN }}
outputs:
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
steps:
Expand All @@ -35,8 +33,6 @@ jobs:
name: Check code formatting
runs-on: ubuntu-latest
needs: calculate-version
env:
LBHPACKAGESTOKEN: ${{ secrets.LBHPACKAGESTOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -50,7 +46,7 @@ jobs:
runs-on: ubuntu-latest
needs: calculate-version
env:
LBHPACKAGESTOKEN: ${{secrets.LBHPACKAGESTOKEN }}
LBHPACKAGESTOKEN: ${{secrets.GITHUB_TOKEN }}
outputs:
version: ${{ needs.calculate-version.outputs.version }}
steps:
Expand All @@ -66,7 +62,6 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-test
env:
LBHPACKAGESTOKEN: ${{secrets.LBHPACKAGESTOKEN }}
VERSION: ${{ needs.build-and-test.outputs.version }}
steps:
- name: Checkout
Expand Down
10 changes: 5 additions & 5 deletions Hackney.Shared.HousingSearch.Tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0

# disable microsoft telematry
ENV DOTNET_CLI_TELEMETRY_OPTOUT='true'

ARG LBHPACKAGESTOKEN
ENV LBHPACKAGESTOKEN=$LBHPACKAGESTOKEN
WORKDIR /app

# Copy csproj and restore as distinct layers
Expand All @@ -13,8 +10,11 @@ COPY ./Hackney.Shared.HousingSearch/Hackney.Shared.HousingSearch.csproj ./Hackne
COPY ./Hackney.Shared.HousingSearch.Tests/Hackney.Shared.HousingSearch.Tests.csproj ./Hackney.Shared.HousingSearch.Tests/
COPY /nuget.config /root/.nuget/NuGet/NuGet.Config

RUN dotnet restore ./Hackney.Shared.HousingSearch/Hackney.Shared.HousingSearch.csproj
RUN dotnet restore ./Hackney.Shared.HousingSearch.Tests/Hackney.Shared.HousingSearch.Tests.csproj
# We mount secrets so they can't end up in logs or build layers.
# see https://docs.docker.com/reference/dockerfile/#arg
RUN --mount=type=secret,id=LBHPACKAGESTOKEN,env=LBHPACKAGESTOKEN \
dotnet restore ./Hackney.Shared.HousingSearch/Hackney.Shared.HousingSearch.csproj && \
dotnet restore ./Hackney.Shared.HousingSearch.Tests/Hackney.Shared.HousingSearch.Tests.csproj

# Copy everything else and build
COPY . .
Expand Down

0 comments on commit c934062

Please sign in to comment.