Update legacy/assets Dockerfile #13
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: Docker (legacy) | |
on: | |
push: | |
branches: [ "legacy" ] | |
tags: [ "v*" ] | |
pull_request: | |
branches: [ "legacy" ] | |
jobs: | |
build: | |
name: Build ${{ matrix.target }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: [ web, reverse-proxy, assets, storage, wvw-crawler ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build the Docker image | |
uses: docker/[email protected] | |
with: | |
workdir: legacy | |
files: docker-compose.yml | |
targets: ${{ matrix.target }} | |
load: true | |
set: | | |
*.cache-from=type=gha,scope=build-${{ matrix.target }} | |
*.cache-to=type=gha,scope=build-${{ matrix.target }},mode=max | |
- name: Login to GitHub Container Registry | |
if: github.event_name == 'push' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image | |
if: github.event_name == 'push' | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository }}/legacy/${{ matrix.target }} | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "legacy" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag gw2treasures/legacy/${{ matrix.target }} $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |