Skip to content

Test: github actions #38

Test: github actions

Test: github actions #38

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "ws_challenge" ]
pull_request:
branches: [ "ws_challenge" ]
env:
APP_NAME: ${{ secrets.APP_NAME }}
NGINX_NAME: ${{ secrets.NGINX_NAME }}
jobs:
build:
#runs-on: [self-hosted, linux, amd64]
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push ${{ env.APP_NAME }} image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.REGISTRY }}/${{ secrets.APP_NAME }}:latest,
${{ secrets.REGISTRY }}/${{ secrets.APP_NAME }}:${{ github.sha }}
no-cache: true
platforms: linux/amd64
-
name: Build and push ${{ env.NGINX_NAME }} image
uses: docker/build-push-action@v5
with:
context: ./nginx/
push: true
tags: |
${{ secrets.REGISTRY }}/${{ secrets.NGINX_NAME }}:latest,
${{ secrets.REGISTRY }}/${{ secrets.NGINX_NAME }}:${{ github.sha }}
no-cache: true
platforms: linux/amd64
Deploy:
runs-on: ubuntu-latest
environment:
name: whitestack
env:
namespace: ${{ secrets.NAMESPACE }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set uo kubeconfig
uses: cryptoexpert2000/base64Secret-toFile-action@v3
with:
secret: ${{ secrets.KUBECONFIG_BASE64 }}
filename: .kubeconfig
destination-path: ${{ runner.workspace }}/.config
env:
KUBECONFIG: ${{ runner.workspace }}/.config/kubeconfig
-
name: Install kubectl
uses: azure/setup-kubectl@v4
-
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ runner.workspace }}/.config/kubeconfig
-
name: verify kubectl and cluster
run: |
kubectl version --client
kubectl cluster-info
-
name: Deploy to Kubernetes
run: |
kubectl apply -f ${{ runner.workspace }}/k8s/. --namespace ${{ env.namespace }}