mirror of
https://github.com/mikefarah/yq.git
synced 2026-06-27 15:37:47 +00:00
* Initial plan * fix: add least-privilege token permissions to GitHub workflows (OSSF) Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/1b5db5e2-af78-4289-a6e0-2e972fc68ef1 Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>
106 lines
4.3 KiB
YAML
106 lines
4.3 KiB
YAML
name: Release Docker
|
|
|
|
on:
|
|
release:
|
|
types: [released]
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
workflow_dispatch:
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
publishDocker:
|
|
environment: dockerhub
|
|
env:
|
|
IMAGE_NAME: mikefarah/yq
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
with:
|
|
version: latest
|
|
|
|
- name: Available platforms
|
|
run: echo ${{ steps.buildx.outputs.platforms }} && docker version
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push image
|
|
run: |
|
|
echo "GithubRef: ${GITHUB_REF}"
|
|
VERSION=${GITHUB_REF##*/}
|
|
echo "VERSION: ${VERSION}"
|
|
IMAGE_VERSION=${VERSION:1}
|
|
echo "IMAGE_VERSION: ${IMAGE_VERSION}"
|
|
|
|
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64,linux/arm/v7,linux/s390x"
|
|
|
|
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
|
|
docker buildx build \
|
|
--label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \
|
|
--label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \
|
|
--label "org.opencontainers.image.description=yq is a portable command-line data file processor" \
|
|
--label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \
|
|
--label "org.opencontainers.image.licenses=MIT" \
|
|
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
|
|
--label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \
|
|
--label "org.opencontainers.image.title=yq" \
|
|
--label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \
|
|
--label "org.opencontainers.image.version=${IMAGE_VERSION}" \
|
|
--platform "${PLATFORMS}" \
|
|
--pull \
|
|
--push \
|
|
-t "${IMAGE_NAME}:${IMAGE_VERSION}" \
|
|
-t "${IMAGE_NAME}:4" \
|
|
-t "${IMAGE_NAME}:latest" \
|
|
-t "ghcr.io/${IMAGE_NAME}:${IMAGE_VERSION}" \
|
|
-t "ghcr.io/${IMAGE_NAME}:4" \
|
|
-t "ghcr.io/${IMAGE_NAME}:latest" \
|
|
.
|
|
|
|
cd github-action
|
|
docker buildx build \
|
|
--label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \
|
|
--label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \
|
|
--label "org.opencontainers.image.description=yq is a portable command-line data file processor" \
|
|
--label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \
|
|
--label "org.opencontainers.image.licenses=MIT" \
|
|
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
|
|
--label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \
|
|
--label "org.opencontainers.image.title=yq" \
|
|
--label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \
|
|
--label "org.opencontainers.image.version=${IMAGE_VERSION}" \
|
|
--platform "${PLATFORMS}" \
|
|
--pull \
|
|
--push \
|
|
-t "${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \
|
|
-t "${IMAGE_NAME}:4-githubaction" \
|
|
-t "${IMAGE_NAME}:latest-githubaction" \
|
|
-t "ghcr.io/${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \
|
|
-t "ghcr.io/${IMAGE_NAME}:4-githubaction" \
|
|
-t "ghcr.io/${IMAGE_NAME}:latest-githubaction" \
|
|
.
|