Fix for docker #69
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 and test image | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- master | |
# cancel outdated jobs for the same reference | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
IMAGE: ${{ github.repository_owner }}/go_tile | |
TAG: ${{ github.sha }} | |
jobs: | |
test: | |
defaults: | |
run: | |
shell: bash | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macos-latest | |
- ubuntu-latest | |
- windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install coreutils (macOS) | |
if: matrix.os == 'macos-latest' | |
run: brew install coreutils | |
- name: Run tests | |
run: make test | |
- name: Generate certificate | |
env: | |
SUBJ: ${{ (matrix.os == 'windows-latest') && '//C=US\ST=None\L=None\O=None\CN=localhost' || '/C=US/ST=None/L=None/O=None/CN=localhost' }} | |
run: | | |
openssl req \ | |
-new \ | |
-newkey rsa:4096 \ | |
-days 365 \ | |
-nodes \ | |
-x509 \ | |
-subj "${SUBJ}" \ | |
-keyout localhost.key \ | |
-out localhost.cert | |
- name: Create metatile directory | |
run: | | |
mkdir -p data/ajt/0/0/0/0/0 | |
ln -s ../../../../../../../mock_data/0.meta data/ajt/0/0/0/0/0/0.meta | |
- name: Build & run server | |
run: | | |
make build | |
./go_tile -tls_cert_path localhost.cert -tls_key_path localhost.key & | |
- name: Fetch & check tile from server | |
env: | |
HTTP_URL: http://localhost:8080/tile/0/0/0.png | |
HTTPS_URL: https://localhost:8443/tile/0/0/0.png | |
SHA256SUM: d038526e9db340fca762fe2f7e04a368583d9150a7d59ed8d27e40e4e3e00719 | |
run: | | |
curl --silent ${HTTP_URL} > tile_http.png | |
curl --insecure --silent ${HTTPS_URL} > tile_https.png | |
echo "${SHA256SUM} tile_http.png" | sha256sum --check --status && \ | |
echo "HTTP SHA256SUM Matching!" | |
echo "${SHA256SUM} tile_https.png" | sha256sum --check --status && \ | |
echo "HTTPS SHA256SUM Matching!" | |
deploy: | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
if: ${{ github.event_name != 'pull_request' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ env.IMAGE }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
pull: true | |
push: true | |
context: . | |
file: docker/Dockerfile.go_tile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha,scope=${{ github.workflow }} | |
cache-to: type=gha,scope=${{ github.workflow }},mode=max |