ci(workflow): remove scheduled build step #275
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 and publish | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
env: | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: nfs-server | |
IMAGES: | | |
docker.io/obeoneorg/nfs-server | |
ghcr.io/obeone/nfs-server | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
# This is used to complete the identity challenge | |
# with sigstore/fulcio when running outside of PRs. | |
id-token: write | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Finding latest release | |
id: version | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
repository: ${{ github.repository }} | |
- name: Parse semver string | |
id: semver_parser | |
uses: booxmedialtd/[email protected] | |
with: | |
input_string: "${{ steps.version.outputs.release }}" | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
images: ${{ env.IMAGES }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=${{ steps.semver_parser.outputs.major }},enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
type=raw,value=${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }},enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
type=raw,value=${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }},enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
type=raw,value=v${{ steps.semver_parser.outputs.major }},enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
type=raw,value=v${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }},enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
type=raw,value=v${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }},enable=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
- name: Build image | |
id: build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
linux/i386 | |
linux/armhf | |
linux/armel | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
pull: true | |
cache-to: type=gha,mode=max | |
cache-from: type=gha,mode=max | |
- name: Sign the images with GitHub OIDC Token | |
run: | | |
set -e | |
# In variables, "%%*( )" trim whitespace at beggining and end of variable | |
for image in ${IMAGES}; do | |
yes | cosign sign "${image%%*( )}@${DIGEST%%*( )}" | |
done | |
env: | |
TAGS: ${{ steps.meta.outputs.tags }} | |
DIGEST: ${{ steps.build.outputs.digest }} | |
COSIGN_EXPERIMENTAL: true | |
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' |