Skip to content

Build container

Build container #116

name: Build container
on:
pull_request:
push:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
env:
ANOPE_VERSION: 2.0.13
DOCKER_REPO: anope/anope
GITHUB_BRANCH: master
GITHUB_REPO: anope/anope-docker
steps:
-
uses: actions/checkout@v3
-
name: Test base image and code version
run: |
ls tests/*.sh | parallel --joblog /tmp/joblog
cat /tmp/joblog
env:
VERSION: ${{ env.ANOPE_VERSION }}
-
name: Pipeline variables
id: pipeline_vars
run: |
EXPECTED="$GITHUB_REPO $GITHUB_BRANCH"
echo "Expected: $EXPECTED"
ACTUAL="${{ github.repository }} ${{ github.ref_name }}"
echo "Actual: $ACTUAL"
if [ "$EXPECTED" == "$ACTUAL" ]
then
echo "On $GITHUB_REPO repo, $GITHUB_BRANCH branch - building all architectures and pushing to Docker Hub"
echo "push=true" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
else
echo "Not on $GITHUB_REPO repo and $GITHUB_BRANCH branch - only building amd64 architecture and not pushing to Docker Hub"
echo "push=false" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
fi
-
name: Prepare environment
run: |
sudo apt-get -qq update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install moby-engine moby-cli
sudo apt-get install -y openssl parallel
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REPO }}
tags: |
type=semver,pattern={{version}},value=${{ env.ANOPE_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.ANOPE_VERSION }}
type=semver,pattern={{major}},value=${{ env.ANOPE_VERSION }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Log in to Docker Hub
if: github.repository == env.GITHUB_REPO && github.ref_name == env.GITHUB_BRANCH
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
build-args: VERSION=${{ env.ANOPE_VERSION }}
platforms: ${{ steps.pipeline_vars.outputs.platforms }}
push: ${{ steps.pipeline_vars.outputs.push }}
tags: ${{ steps.meta.outputs.tags }}
-
name: Update description on Docker Hub
if: github.repository == env.GITHUB_REPO && github.ref_name == env.GITHUB_BRANCH
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ env.DOCKER_REPO }}
short-description: Anope IRC Services https://anope.org
readme-filepath: README.md