deploy on rancher #8
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: deploy on rancher | |
on: | |
workflow_dispatch: ~ | |
release: | |
types: [published] | |
env: | |
RANCHER_API_BASE: https://rancher.acdh-dev.oeaw.ac.at/v3 | |
RANCHER_PROJECT: Dissemination services | |
RANCHER_NAMESPACE: arche-mapserver | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
#- name: test | |
# run: | | |
# composer update | |
# vendor/bin/phpunit tests | |
- name: build docker image | |
run: | | |
git reset --hard HEAD | |
rm -fR vendor | |
mkdir build/docroot && cp -R `ls -1 | grep -v ^build` build/docroot/ && cp .htaccess build/docroot/ && cp build/arche/* build/docroot/ | |
docker build --rm -t "acdhch/$RANCHER_NAMESPACE:latest" --build-arg VARIANT=production --label "buildUrl=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" build | |
- name: test image | |
run: | | |
docker run -d --name "$RANCHER_NAMESPACE" -p 8080:80 "acdhch/$RANCHER_NAMESPACE:latest" | |
sleep 1 | |
docker exec "$RANCHER_NAMESPACE" sed -i -e 's/baseUrl: .*/baseUrl: http:\/\/127.0.0.1:8080\/cgi-bin\/mapserv/' /var/www/html/config.yaml | |
docker exec "$RANCHER_NAMESPACE" /var/www/html/download.sh | |
curl -f -L -i 'http://127.0.0.1:8080/mapserv?map=/data/czoernig.map&mode=tile&layers=czoernig&tilemode=gmap&tile=8+5+4' | |
curl -f -L -i 'http://127.0.0.1:8080/?id=https%3A%2F%2Farche.acdh.oeaw.ac.at%2Fapi%2F108089&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities' | |
curl -f -L -i 'http://127.0.0.1:8080/?id=https%3A%2F%2Farche.acdh.oeaw.ac.at%2Fapi%2F108089&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities' | |
docker exec "$RANCHER_NAMESPACE" cat /var/www/html/log | |
- name: authorize against docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: push to docker hub | |
run: docker push "acdhch/$RANCHER_NAMESPACE:latest" | |
- name: redeploy on rancher | |
run: | | |
BASE_URL=`curl -s -H "Authorization: Bearer ${{ secrets.RANCHERTOKEN }}" "$RANCHER_API_BASE/projects" | jq -r ".data[] | select(.name == \"$RANCHER_PROJECT\") | .links.workloads"` | |
curl -i -X POST -H "Authorization: Bearer ${{ secrets.RANCHERTOKEN }}" "$BASE_URL/deployment:$RANCHER_NAMESPACE:$RANCHER_NAMESPACE?action=redeploy" | |