Skip to content

ci(ghcr): try different token #33

ci(ghcr): try different token

ci(ghcr): try different token #33

name: Build
on:
pull_request:
branches:
- 'main'
push:
branches:
- 'main'
env:
DOCKER_CONTEXT_DIR: "{{defaultContext}}:images/release"
DOCKER_IMAGE: "ghcr.io/${{ github.repository }}-release"
DOCKER_PLATFORMS: "linux/amd64,linux/arm64"
PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
jobs:
docker:
name: Docker build
runs-on: ubuntu-latest
steps:
- name: Checkout Current
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=ref,event=branch
type=raw,value=latest
- 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.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.DOCKER_CONTEXT_DIR }}
platforms: ${{ inputs.docker_platforms }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha
cache-from: type=gha
version:
name: Semantic release
needs: docker
runs-on: ubuntu-latest
outputs:
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
id: semantic
with:
semantic_version: 16
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ env.PAT }}
docker_release:
name: Docker release
needs: version
if: ${{ needs.version.outputs.new_release_published == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Current
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: ${{ env.DOCKER_IMAGE }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}},value=${{ needs.version.outputs.new_release_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.version.outputs.new_release_version }}
type=semver,pattern={{major}},value=${{ needs.version.outputs.new_release_version }}
- 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@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.DOCKER_CONTEXT_DIR }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha