chore: update ps3netsrv to 20240709 #108
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 | |
on: | |
push: | |
paths-ignore: | |
- '*.md' | |
- '**/*.md' | |
# Publish `main` as Docker `edge` image. | |
branches: | |
- main | |
- develop | |
- 'release/*' | |
tags: | |
- 'v*.*.*' | |
# Run tests for any PRs. | |
pull_request: | |
env: | |
IMAGE_NAME: ps3netsrv | |
IMAGE_TITLE: ps3netsrv | |
IMAGE_DESCRIPTION: Docker container for ps3netsrv | |
APP_VERSION: "20240709" | |
RELEASE_TAG: "1.47.47" | |
jobs: | |
# Run tests. | |
# See also https://docs.docker.com/docker-hub/builds/automated-testing/ | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
id: buildx_test | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.test-buildx-cache | |
key: ${{ runner.os }}-test-buildx-${{ env.APP_VERSION }} | |
restore-keys: | | |
${{ runner.os }}-test-buildx-${{ env.APP_VERSION }} | |
${{ runner.os }}-test-buildx- | |
- name: Test build | |
id: docker_build_test | |
uses: docker/build-push-action@v6 | |
with: | |
builder: ${{ steps.buildx_test.outputs.name }} | |
context: . | |
platforms: linux/amd64 | |
push: false | |
build-args: | | |
PS3NETSRV_RELEASE=${{ env.RELEASE_TAG }} | |
PS3NETSRV_VERSION=${{ env.APP_VERSION }} | |
cache-from: type=local,src=/tmp/.test-buildx-cache | |
cache-to: type=local,dest=/tmp/.test-buildx-cache-new | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.test-buildx-cache | |
mv /tmp/.test-buildx-cache-new /tmp/.test-buildx-cache | |
# Build images. | |
build: | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKERIO_IMAGE=docker.io/${{ github.repository_owner }}/$IMAGE_NAME | |
GHCRIO_IMAGE=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
# Strip git ref prefix from version | |
VERSION_FULL=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\)$,\1,') | |
VERSION_MINOR=$(echo "$VERSION_FULL" | sed 's,\.[^.]*$,,') | |
VERSION_MAJOR=$(echo "$VERSION_MINOR" | sed 's,\.[^.]*$,,') | |
# Use Docker `edge` tag convention and pr-<number> for pull requests | |
[ "$VERSION_FULL" == "main" ] && VERSION_FULL=edge | |
[ ${{ github.ref }} == refs/pull/* ] && VERSION_FULL=pr-${{ github.event.number }} | |
# Build all tags | |
DOCKERIO_TAGS="${DOCKERIO_IMAGE}:${VERSION_FULL}" | |
[ "$VERSION_FULL" != "edge" ] && DOCKERIO_TAGS="$DOCKERIO_TAGS,${DOCKERIO_IMAGE}:${VERSION_MINOR},${DOCKERIO_IMAGE}:${VERSION_MAJOR},${DOCKERIO_IMAGE}:${APP_VERSION},${DOCKERIO_IMAGE}:latest" | |
[ "$VERSION_FULL" == "edge" ] && DOCKERIO_TAGS="$TAGS,${DOCKERIO_IMAGE}:${VERSION_FULL}-${APP_VERSION}" | |
GHCRIO_TAGS="${GHCRIO_IMAGE}:${VERSION_FULL}" | |
[ "$VERSION_FULL" != "edge" ] && GHCRIO_TAGS="$GHCRIO_TAGS,${GHCRIO_IMAGE}:${VERSION_MINOR},${GHCRIO_IMAGE}:${VERSION_MAJOR},${GHCRIO_IMAGE}:${APP_VERSION},${GHCRIO_IMAGE}:latest" | |
[ "$VERSION_FULL" == "edge" ] && GHCRIO_TAGS="$GHCRIO_TAGS,${GHCRIO_IMAGE}:${VERSION_FULL}-${APP_VERSION}" | |
# Build tags for README.md | |
[ "$VERSION_FULL" != "edge" ] && README_TAGS="\`latest\`, \`${VERSION_MAJOR}\`, \`${VERSION_MINOR}\`, \`${VERSION_FULL}\`, \`${APP_VERSION}\`" | |
[ "$VERSION_FULL" == "edge" ] && README_TAGS="\`${VERSION_FULL}\`, \`${VERSION_FULL}-${APP_VERSION}\`" | |
# Replace supported latest tags in README.md | |
if [ "$VERSION_FULL" != "edge" ]; then | |
sed -i '/- `latest`.*<!-- latest tag -->/c- '"${README_TAGS}"' <!-- latest tag -->' README.md | |
fi | |
# Replace supported edge tags in README.md | |
if [ "$VERSION_FULL" == "edge" ]; then | |
sed -i '/- `edge`.*<!-- edge tag -->/c- '"${README_TAGS}"' <!-- edge tag -->' README.md | |
fi | |
# Use Docker `edge` tag convention and pr-<number> for pull requests | |
[ "$VERSION_FULL" == "main" ] && VERSION_FULL=edge | |
[ ${{ github.ref }} == refs/pull/* ] && VERSION_FULL=pr-${{ github.event.number }} | |
# Build tags for README.md | |
[ "$VERSION_FULL" != "edge" ] && README_TAGS="\`latest\`, \`${VERSION_MAJOR}\`, \`${VERSION_MINOR}\`, \`${VERSION_FULL}\`, \`${APP_VERSION}\`" | |
[ "$VERSION_FULL" == "edge" ] && README_TAGS="\`${VERSION_FULL}\`, \`${VERSION_FULL}-${APP_VERSION}\`" | |
echo "version=${VERSION_FULL}" >> $GITHUB_OUTPUT | |
echo "tags=${DOCKERIO_TAGS},${GHCRIO_TAGS}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
echo "readme_tags=${README_TAGS}" >> $GITHUB_OUTPUT | |
echo "release=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') }}" >> $GITHUB_OUTPUT | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ env.APP_VERSION }} | |
restore-keys: | | |
${{ runner.os }}-buildx-${{ env.APP_VERSION }} | |
${{ runner.os }}-buildx- | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 | |
push: ${{ steps.prep.outputs.release == 'true' }} | |
tags: ${{ steps.prep.outputs.tags }} | |
build-args: | | |
PS3NETSRV_RELEASE=${{ env.RELEASE_TAG }} | |
PS3NETSRV_VERSION=${{ env.APP_VERSION }} | |
labels: | | |
org.opencontainers.image.title=$IMAGE_TITLE | |
org.opencontainers.image.description=$IMAGE_DESCRIPTION | |
org.opencontainers.image.vendor=${{ github.repository_owner }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.version=$APP_VERSION | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
- name: Checkout main | |
if: steps.prep.outputs.release == 'true' | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Update README.md | |
if: steps.prep.outputs.release == 'true' | |
id: update-readme | |
run: | | |
# Replace supported latest tags in README.md | |
if [ "${{ steps.prep.outputs.version }}" != "edge" ]; then | |
sed -i '/- `latest`.*<!-- latest tag -->/c- ${{ steps.prep.outputs.readme_tags }} <!-- latest tag -->' README.md | |
fi | |
# Replace supported edge tags in README.md | |
if [ "${{ steps.prep.outputs.version }}" == "edge" ]; then | |
sed -i '/- `edge`.*<!-- edge tag -->/c- ${{ steps.prep.outputs.readme_tags }} <!-- edge tag -->' README.md | |
fi | |
- name: Check for modified files | |
if: steps.prep.outputs.release == 'true' | |
id: git-check | |
run: echo modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") >> $GITHUB_OUTPUT | |
- name: Commit updated README.md | |
if: steps.git-check.outputs.modified == 'true' | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git add README.md | |
git commit -m "docs(README): update supported tags" | |
git push | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |