Build container #299
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: Build container | |
on: | |
pull_request: | |
push: | |
schedule: | |
- cron: '0 0 * * 1' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
env: | |
DOCKER_REPO: inspircd/inspircd-docker | |
GITHUB_BRANCH: master | |
GITHUB_REPO: inspircd/inspircd-docker | |
INSP_VERSION: v3.17.1 | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
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: Build and test amd64 image | |
run: | | |
IP=$(ip addr s \ | |
| grep global \ | |
| grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' \ | |
| head -n1) | |
echo "docker swarm init on $IP" | |
docker swarm init --advertise-addr $IP | |
docker build --build-arg VERSION="${INSP_VERSION}" -t inspircd:testing . | |
echo "* * * Image built, running tests... * * *" | |
./run_tests.sh | |
echo "* * * Tests OK! * * *" | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REPO }} | |
tags: | | |
type=semver,pattern={{version}},value=${{ env.INSP_VERSION }} | |
type=semver,pattern={{major}}.{{minor}},value=${{ env.INSP_VERSION }} | |
type=semver,pattern={{major}},value=${{ env.INSP_VERSION }} | |
- | |
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 Docker Hub | |
if: github.repository == env.GITHUB_REPO && github.ref_name == env.GITHUB_BRANCH | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
build-args: VERSION=${{ env.INSP_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@v4 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
repository: ${{ env.DOCKER_REPO }} | |
short-description: Official image for InspIRCd Internet Relay Chat server. https://www.inspircd.org | |
readme-filepath: README.md |