Skip to content

iproute2

iproute2 #15

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: build
on:
push:
branches:
- '**'
tags-ignore:
- '*.*'
release:
types:
- published
env:
IMAGE_NAME: keepalived-swarm
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Docker Build
run: docker build -t "$IMAGE_NAME" --label "runnumber=${GITHUB_RUN_ID}" .
- name: Log in to GitHub Container Registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.GITHUB_TOKEN }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Push image to GitHub Container Registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.GITHUB_TOKEN }}
run: |
IMAGE_ID="ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME"
# Change all uppercase to lowercase
IMAGE_ID=$(echo "$IMAGE_ID" | tr '[A-Z]' '[a-z]')
if [[ '${{ github.event_name }}' == 'release' ]]; then
# Set tags to `latest`
TAGS=(latest)
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ '${{ github.ref }}' =~ ^refs/tags/v[0-9]+\.[0-9] ]] && VERSION=$(echo "$VERSION" | sed -e 's/^v//')
# Add version to tags
[[ "$VERSION" != "main" ]] && TAGS+=("$VERSION")
else
# Set tags to commit hash
TAGS=("${GITHUB_SHA::8}")
fi
for TAG in "${TAGS[@]}"; do docker tag "$IMAGE_NAME" "$IMAGE_ID:$TAG"; done
for TAG in "${TAGS[@]}"; do docker push "$IMAGE_ID:$TAG"; done
- name: Log into Docker Hub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.GITHUB_TOKEN }}
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Push image to Docker Hub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.GITHUB_TOKEN }}
run: |
IMAGE_ID="${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME"
# Change all uppercase to lowercase
IMAGE_ID=$(echo "$IMAGE_ID" | tr '[A-Z]' '[a-z]')
if [[ '${{ github.event_name }}' == 'release' ]]; then
# Set tags to `latest`
TAGS=(latest)
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ '${{ github.ref }}' =~ ^refs/tags/v[0-9]+\.[0-9] ]] && VERSION=$(echo "$VERSION" | sed -e 's/^v//')
# Add version to tags
[[ "$VERSION" != "main" ]] && TAGS+=("$VERSION")
else
# Set tags to commit hash
TAGS=("${GITHUB_SHA::8}")
fi
for TAG in "${TAGS[@]}"; do docker tag "$IMAGE_NAME" "$IMAGE_ID:$TAG"; done
for TAG in "${TAGS[@]}"; do docker push "$IMAGE_ID:$TAG"; done