Authenticate with CIR using OIDC #283
Workflow file for this run
This file contains 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: PR | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.21.x" | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
- name: Install dependencies | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
run: go get | |
- name: Build | |
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo | |
docker-push: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Tag | |
run: | | |
CLEAN_TAG=$(echo "${{ github.event.pull_request.head.ref }}" | tr / -) | |
echo "TAG=$CLEAN_TAG" >> $GITHUB_ENV | |
- name: Build | |
run: > | |
docker build -t onsdigital/eq-questionnaire-launcher:$TAG | |
-t ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-launcher:$TAG . | |
- name: Push to Docker Hub | |
run: | | |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
echo "Pushing with tag [$TAG]" | |
docker push onsdigital/eq-questionnaire-launcher:$TAG | |
- name: Push to GAR | |
env: | |
GAR_SERVICE_KEY: ${{ secrets.GAR_SERVICE_KEY }} | |
run: | | |
echo $GAR_SERVICE_KEY | docker login -u _json_key --password-stdin https://${{ secrets.GAR_LOCATION }} | |
gcloud auth configure-docker ${{ secrets.GAR_LOCATION }} | |
echo "Pushing to GAR with tag $TAG" | |
docker push ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-launcher:$TAG |