Skip to content

Commit

Permalink
FIx build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman authored May 2, 2024
1 parent cdd0fbb commit 33b1d1f
Showing 1 changed file with 53 additions and 48 deletions.
101 changes: 53 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,69 +12,74 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Get git tag
id: git_info
if: startsWith(github.ref, 'refs/tags/')
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Determine image tags
id: determine
env:
git_tag: ${{ steps.git_info.outputs.tag }}
- name: Decide image tags
id: info
shell: python
run: |
repo="${GITHUB_REPOSITORY,,}" # to lower case
tag="${git_tag:-latest}" # if build triggered by tag, use tag name
echo "::set-output name=repo::$repo"
echo "::set-output name=tag::$tag"
echo "::set-output name=dock_image::$repo:$tag"
import os
import itertools
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
id: buildx
- name: Cache Docker layers
uses: actions/cache@v2
def join_tag(t):
registry, repo, tag = t
return f'{registry}/{repo}:{tag}'.lower()
registries = ['docker.io', 'ghcr.io']
repos = ['${{ github.repository }}']
if '${{ github.ref_type }}' == 'branch':
tags = ['latest']
elif '${{ github.ref_type }}' == 'tag':
tag = '${{ github.ref_name }}'
version = tag[1:] if tag.startswith('v') else tag
tags = ['latest', version]
else:
tags = []
product = itertools.product(registries, repos, tags)
tags_csv = ','.join(map(join_tag, product))
outputs = {
'tags_csv' : tags_csv,
'push' : 'true' if tags_csv else 'false',
}
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
for k, v in outputs.items():
out.write(f'{k}={v}\n')
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
driver-opts: network=host

- name: Login to DockerHub
uses: docker/login-action@v1
if: (github.event_name == 'push' || github.event_name == 'release') && contains(steps.info.outputs.tags_csv, 'docker.io')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: (github.event_name == 'push' || github.event_name == 'release') && contains(steps.info.outputs.tags_csv, 'ghcr.io')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
if: (github.event_name == 'push' || github.event_name == 'release')
with:
push: true
tags: |
${{ steps.determine.outputs.dock_image }}
ghcr.io/${{ steps.determine.outputs.dock_image }}
context: .
file: ./Dockerfile
tags: ${{ steps.info.outputs.tags_csv }}
platforms: linux/amd64,linux/ppc64le,linux/arm64,linux/arm/v7
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
PushContainerReadme:
runs-on: ubuntu-latest
name: Push README to Docker Hub
steps:
- name: git checkout
uses: actions/checkout@v2
- name: push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}
push: ${{ steps.info.outputs.push }}
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: actions/checkout@v4
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v3
with:
destination_container_repo: fnndsc/pfbridge
provider: dockerhub
short_description: 'A bridge between clinical services and pflink'
readme_file: 'README.md'
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: 'A bridge between clinical services and pflink'
readme-filepath: ./README.md

0 comments on commit 33b1d1f

Please sign in to comment.