justinbarry for the devterm #11
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: ci | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: [ main ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
update: | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build | |
run: cargo build --release --all-features --verbose | |
- name: Run tests | |
run: cargo test --verbose | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
irishgordo/gophergordo | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Set up WireGuard Connection | |
if: github.event_name != 'pull_request' | |
uses: niklaskeerl/easy-wireguard-action@v2 | |
with: | |
WG_CONFIG_FILE: ${{ secrets.WG_CONFIG_FILE }} | |
- name: Add hosts to /etc/hosts | |
if: github.event_name != 'pull_request' | |
run: | | |
sudo echo "${{ secrets.WG_RANCHER_HOST }}" | sudo tee -a /etc/hosts | |
- name: Kubernetes context | |
if: github.event_name != 'pull_request' | |
uses: Azure/k8s-set-context@v1 | |
with: | |
method: kubeconfig | |
kubeconfig: ${{ secrets.RKE2_CLUSTER_BUILT_ON_HARVESTER_W_TERRAFORM_KUBECONFIG }} | |
namespace: default | |
- name: Deploy | |
if: github.event_name != 'pull_request' | |
run: kubectl rollout restart deployment gordogopherhole --namespace=default | |
- name: Wait for rollout to finish | |
if: github.event_name != 'pull_request' | |
run: kubectl rollout status deployment gordogopherhole --namespace=default |