Skip to content

start gh actions workflows #129

start gh actions workflows

start gh actions workflows #129

Workflow file for this run

name: WG-Easy Image CI
on:
push:
branches: [ main ]
paths:
- 'applications/wg-easy/**'
- '.github/workflows/wg-easy-image.yml'
pull_request:
paths:
- 'applications/wg-easy/**'
- '.github/workflows/wg-easy-image.yml'
workflow_dispatch:
env:
DEV_CONTAINER_REGISTRY: ghcr.io
DEV_CONTAINER_IMAGE: replicatedhq/platform-examples/wg-easy-tools
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
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: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.DEV_CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set branch variables
id: vars
run: |
# Get branch name and normalize to lowercase with hyphens
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
NORMALIZED_BRANCH=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | tr '/' '-')
IS_MAIN=${{ github.ref_name == 'main' || github.ref_name == 'refs/heads/main' }}
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "normalized-branch=$NORMALIZED_BRANCH" >> $GITHUB_OUTPUT
echo "is-main=$IS_MAIN" >> $GITHUB_OUTPUT
echo "Branch: $BRANCH_NAME, Normalized: $NORMALIZED_BRANCH, Is Main: $IS_MAIN"
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.DEV_CONTAINER_IMAGE }}
tags: |
# Main branch tags
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=sha-{{sha}},enable={{is_default_branch}}
# Non-main branch tags - branch name as "latest" for that branch
type=raw,value=${{ steps.vars.outputs.normalized-branch }},enable=${{ steps.vars.outputs.is-main == 'false' }}
# SHA-suffixed tags for all branches (main and non-main)
type=raw,value=${{ steps.vars.outputs.normalized-branch }}-sha-{{sha}},enable=${{ steps.vars.outputs.is-main == 'false' }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: applications/wg-easy
file: applications/wg-easy/container/Containerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max