Build container #186
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: | |
ANOPE_VERSION: 2.0.15 | |
DOCKER_REPO: anope/anope | |
GITHUB_BRANCH: master | |
GITHUB_REPO: anope/anope-docker | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
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: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
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@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.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@v4 | |
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 |