Skip to content

Commit

Permalink
make push to ghcr conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
nithyatsu committed Oct 30, 2023
1 parent 84796d2 commit 3f20368
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 41 deletions.
41 changes: 9 additions & 32 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,15 @@ concurrency:
env:
VERSION: ${{ github.event.pull_request.number || 'latest' }}
# Use ghcr.io/radius-project/dev for PR build. Otherwise, use ghcr.io/radius-project.
CONTAINER_REGISTRY: ${{ github.event.pull_request.number && 'k3d-myregistry.localhost:5050/radius-project/dev' || 'k3d-myregistry.localhost:5050/radius-project' }}
CONTAINER_REGISTRY: ${{ github.event.pull_request.number && 'ghcr.io/radius-project/dev' || 'ghcr.io/radius-project' }}
# Set to true to push images to registry.
PUSH_IMAGE: true

jobs:
setup-cluster:
name: create cluster with local registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Download k3d
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- name: Create registry
run: k3d registry create myregistry --port 5050
- name: Create k3d cluster
id: create-k3d-cluster
run: |
echo "testing local registry ....................."
k3d cluster create --agents 1 --k3s-arg "--disable=traefik@server:0" --registry-use myregistry:5050
PORT="$(docker ps -f name=myregistry)"
echo "$PORT"
build-ghcr:
name: Build and push sample images to GHCR
if: github.event.action != 'closed'
runs-on: ubuntu-latest
needs: setup-cluster
permissions:
contents: read
packages: write
Expand All @@ -69,20 +50,16 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download k3d
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- name: Create registry
run: k3d registry create myregistry --port 5050
- name: Create k3d cluster
id: create-k3d-cluster
run: |
echo "testing local registry ....................."
k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-use myregistry:5050
PORT="$(docker ps -f name=mycluster-registry)"
echo "$PORT"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v4
with:
context: ./${{ matrix.directory }}
if: github.event_name == 'push'
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/${{ matrix.image }}:${{ env.VERSION }}
11 changes: 2 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,16 @@ jobs:
done
timeout-minutes: 60
continue-on-error: false
- name: Update eks
- name: Install k3d
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'aws'
run: |
aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }}
- name: Download k3d
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential != 'aws'
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- name: Create registry
run: k3d registry create myregistry --port 5050
- name: Create k3d cluster
id: create-k3d-cluster
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential != 'aws'
run: |
echo "testing local registry ....................."
k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-use myregistry:5050
PORT="$(docker ps -f name=mycluster-registry)"
echo "$PORT"
run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0"
- name: Install Dapr
if: steps.gen-id.outputs.RUN_TEST == 'true' && steps.gen-id.outputs.ENABLE_DAPR == 'true'
run: |
Expand Down

0 comments on commit 3f20368

Please sign in to comment.