This repository has been archived by the owner on Feb 21, 2025. It is now read-only.
Merge pull request #134 from crazy-max/gha-perms #170
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 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions | |
permissions: | |
contents: read | |
on: | |
push: | |
branches: | |
- 'master' | |
tags: | |
- 'v*' | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
branches: | |
- 'master' | |
- 'v*' | |
paths-ignore: | |
- '**.md' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
# required to create GitHub release | |
contents: write | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: GitHub Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
draft: true | |
files: | | |
csgo-server-launcher.conf | |
csgo-server-launcher.sh | |
install.sh | |
docker: | |
runs-on: ubuntu-latest | |
permissions: | |
# same as global permissions | |
contents: read | |
# required to push to GHCR | |
packages: write | |
needs: release | |
env: | |
DOCKERHUB_SLUG: crazymax/csgo-server-launcher | |
GHCR_SLUG: ghcr.io/crazy-max/csgo-server-launcher | |
steps: | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DOCKERHUB_SLUG }} | |
${{ env.GHCR_SLUG }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=ref,event=pr | |
type=edge | |
labels: | | |
org.opencontainers.image.title=CSGO Server Launcher | |
org.opencontainers.image.description=Create and launch your Counter-Strike Global Offensive Dedicated Server | |
org.opencontainers.image.vendor=CrazyMax | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- | |
name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build | |
uses: docker/bake-action@v6 | |
with: | |
files: | | |
./docker-bake.hcl | |
cwd://${{ steps.meta.outputs.bake-file }} | |
targets: image | |
push: ${{ github.event_name != 'pull_request' }} | |
- | |
name: Check manifest | |
if: github.event_name != 'pull_request' | |
run: | | |
docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }} | |
docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }} | |
- | |
name: Inspect image | |
if: github.event_name != 'pull_request' | |
run: | | |
docker pull ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }} | |
docker image inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }} | |
docker pull ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }} | |
docker image inspect ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }} |