Skip to content

update

update #155

Workflow file for this run

name: build
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5.2
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.8.0
with:
setup-tools: |
yq
yq: "4.16.2"
- name: Docker Build
run: docker build . -t xctf
- if: ${{ !(github.event_name == 'push' && github.ref == 'refs/heads/main') }}
run: exit 0
- name: Log into registry
if: steps.branch-name.outputs.current_branch == 'main'
run: echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push backend image
if: steps.branch-name.outputs.current_branch == 'main'
run: |
SERVER_IMAGE_ID=ghcr.io/xctf-io/xctf
# Change all uppercase to lowercase
SERVER_IMAGE_ID=$(echo $SERVER_IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo SERVER_IMAGE_ID=$SERVER_IMAGE_ID
echo VERSION=$VERSION
docker tag xctf $SERVER_IMAGE_ID:$VERSION
docker push $SERVER_IMAGE_ID:$VERSION