Only publish images to repo on tag, distinguish between latest and la… #117
Workflow file for this run
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 | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Checkout qwc-docker | |
uses: actions/checkout@master | |
with: | |
repository: qwc-services/qwc-docker | |
path: qwc-docker | |
- name: Start required services | |
run: | | |
cd qwc-docker | |
sed -i 's|qwc-solr:|localhost:|' volumes/config/default/searchConfig.json | |
# This is needed, because solr generates files and needs permissions to store them | |
# in volumes/solr/* | |
chmod 777 -R volumes/solr/ | |
docker-compose -f docker-compose-example.yml up -d qwc-solr | |
- name: Setting up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Run unittests | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements.txt | |
CONFIG_PATH=$PWD/qwc-docker/volumes/config/ python test.py | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@master | |
- name: Get version tag | |
id: get_tag | |
run: | | |
if [ ${{ endsWith(github.ref, '-lts') }} = true ]; then | |
echo "tag=latest-lts,${GITHUB_REF:10}" >>$GITHUB_OUTPUT | |
else | |
echo "tag=latest,${GITHUB_REF:10}" >>$GITHUB_OUTPUT | |
fi | |
- name: Publish to Registry | |
uses: elgohr/Publish-Docker-Github-Action@v5 | |
if: github.event_name != 'pull_request' | |
with: | |
name: sourcepole/${{ github.event.repository.name }} | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
tags: "${{ steps.get_tag.outputs.tag }}" |