Skip to content

Commit

Permalink
update GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangqingW committed Aug 16, 2024
1 parent 9095ee9 commit 31f0bc7
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 164 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
^\.github$
^data-raw$
^LICENSE\.md$
^CODE_OF_CONDUCT\.md$
^\.BBSoptions$
^Dockerfile$
^_pkgdown\.yml$
124 changes: 0 additions & 124 deletions .github/workflows/basic_checks.yaml

This file was deleted.

98 changes: 58 additions & 40 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ name: R-CMD-check-bioc
env:
has_testthat: 'false'
run_covr: 'false'
run_pkgdown: 'false'
run_pkgdown: 'true'
has_RUnit: 'false'
cache-version: 'cache-v1'
run_docker: 'false'
Expand Down Expand Up @@ -289,51 +289,69 @@ jobs:
name: ${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-results
path: check


## Code adapted from
## https://github.com/waldronlab/cBioPortalData/blob/e0440a4445f0cc731e426363a76faa22ee5e0f9d/.github/workflows/devel_check_dock.yml#L65-L92
docker-build-and-push:
#needs: r-build-and-check
runs-on: ubuntu-latest
needs: build-check
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: Checkout Repository
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Register repo name
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
id: reg_repo_name
- name: Set Environment Variables
run: |
echo CONT_IMG_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Set up QEMU
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
uses: docker/login-action@v2
REPO_LOWER="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
REGISTRY=ghcr.io
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "REGISTRY=${REGISTRY}" >> $GITHUB_ENV
echo "IMAGE=${REGISTRY}/${REPO_LOWER}" >> $GITHUB_ENV
- name: Show environment
run: |
env
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
## Note that DOCKERHUB_TOKEN is really a token for your dockerhub
## account, not your actual dockerhub account password. You can get it
## from https://hub.docker.com/settings/security.
## Check https://github.com/docker/build-push-action/tree/v4.0.0
## for more details.
## Alternatively, try checking
## https://seandavi.github.io/BuildABiocWorkshop/articles/HOWTO_BUILD_WORKSHOP.html.

- name: Build and Push Docker
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel' && success()"
uses: docker/build-push-action@v4
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: >
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:latest,
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ env.GIT_SHA }}

0 comments on commit 31f0bc7

Please sign in to comment.