Hey Alan,

I think the line "container: almurphy/scfdev:latest" should be removed, this 
should only be used if you want to run something within a container (in this 
case, you just want to create a container).

Also, you are using docker/build-push-action@v2 as if it was version 1, but 
they changed a lot this action in the new version, as you can see here: 
https://github.com/docker/build-push-action/blob/master/UPGRADE.md 
<https://github.com/docker/build-push-action/blob/master/UPGRADE.md>

I would remove the 

> - name: Build and push
>         uses: docker/build-push-action@v2
>         with:
>           push: true
>           username: ${{ secrets.DOCKER_USERNAME }}
>           password: ${{ secrets.DOCKER_TOKEN }}
>           repository: almurphy/scfdev
>           tag_with_ref: true
>           tag_with_sha: true
>           tags: ${{ github.repository }}:${{ env.packageVersion }}

and replace it with the following:

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          push: true
          tags: ${{ github.repository}}:${{ env.packageVersion }}

Basically, the steps are more discrete now, tell me if it works and if you need 
help with anything else.

Cheers,
Nuno

> On 3 Jun 2021, at 20:17, Murphy, Alan E <a.mur...@imperial.ac.uk> wrote:
> 
> Hey Nuno,
> 
> Thanks so much, see below.
> 
> Kind regards,
> Alan.
> 
> name: R GitHub Actions
> 
> on:
>   push:
>     branches:
>       - main
>       - master
>       - dev-am
>   pull_request:
>     branches:
>       - main
>       - master
> 
> jobs:
>   R-CMD-check:
>     name: R-CMD-check
>     runs-on: ubuntu-latest
>     container: almurphy/scfdev:latest
>     env:
>       GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
>       RGL_USE_NULL: TRUE
>     steps:
>       - uses: actions/checkout@v2
>       - name: Setup R
>         uses: r-lib/actions/setup-r@v1
>         with:
>           install-r: false
> 
>       - name: Install dependencies
>         run: |
>           install.packages(c("remotes", "rcmdcheck"))
>           remotes::install_deps(dependencies = TRUE)
>         shell: Rscript {0}
>       - name: Check
>         run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
>         shell: Rscript {0}
>         
>       - name: Get R package version
>         run: |
>           version=$(grep Version DESCRIPTION | grep -o "[0-9.]\+")
>           echo "packageVersion=${version}" >> $GITHUB_ENV
>         shell: bash {0}
>         
>       - name: Build and push
>         uses: docker/build-push-action@v2
>         with:
>           push: true
>           username: ${{ secrets.DOCKER_USERNAME }}
>           password: ${{ secrets.DOCKER_TOKEN }}
>           repository: almurphy/scfdev
>           tag_with_ref: true
>           tag_with_sha: true
>           tags: ${{ github.repository }}:${{ env.packageVersion }}
> From: Nuno Agostinho <nunodanielagosti...@gmail.com 
> <mailto:nunodanielagosti...@gmail.com>>
> Sent: 03 June 2021 20:15
> To: Murphy, Alan E <a.mur...@imperial.ac.uk <mailto:a.mur...@imperial.ac.uk>>
> Cc: bioc-devel@r-project.org <mailto:bioc-devel@r-project.org> 
> <bioc-devel@r-project.org <mailto:bioc-devel@r-project.org>>
> Subject: Re: [Bioc-devel] Add dockerhub push to github repository
>  
> Hey Alan,
> 
>> is that installing the master branch or the current branch that has been 
>> pushed to?
> 
> 
> It is based on the current branch.
> 
>> Building image [***/scfdev:combiz/scFlow:0.7.1 ***/scfdev:dev-am 
>> ***/scfdev:sha-658a6af]
>> invalid argument "***/scfdev:combiz/scFlow:0.7.1" for "-t, --tag" flag: 
>> invalid reference format
> 
> 
> I don't think the problem is the Dockerfile, but the GitHub Actions workflow 
> itself (specifically, the issue seems to be related with the tag of the 
> image). Could you show me your GitHub Actions workflow file to check what is 
> going on?
> 
> Cheers,
> Nuno
> 
>> On 3 Jun 2021, at 20:05, Murphy, Alan E <a.mur...@imperial.ac.uk 
>> <mailto:a.mur...@imperial.ac.uk>> wrote:
>> 
>> Hey Nuno,
>> 
>> Thank you very much for your comprehensive explanation!
>> 
>> I have a question regarding the `remotes::install_local()` approach in the 
>> dockerfile, is that installing the master branch or the current branch that 
>> has been pushed to? I ask as I'm working on 'dev-am' branch and I got the 
>> following error:
>> 
>> Building image [***/scfdev:combiz/scFlow:0.7.1 ***/scfdev:dev-am 
>> ***/scfdev:sha-658a6af]
>> invalid argument "***/scfdev:combiz/scFlow:0.7.1" for "-t, --tag" flag: 
>> invalid reference format
>> See 'docker build --help'.
>> Error: Error: exit status 125
>> Usage:
>>   github-actions build-push [flags]
>> 
>> Flags:
>>   -h, --help   help for build-push
>> 
>> exit status 125
>> 
>> Obviously, this may not be down to this but I'm just trying to rule things 
>> out since this was the only change I made to the dockerfile. The docker file 
>> has this added following your dockerfile:
>> 
>> ## Install scFlow package
>> # Copy description
>> WORKDIR scFlow
>> ADD . .
>> 
>> # Install R package from source
>> RUN Rscript -e "remotes::install_local()"
>> RUN rm -rf *
>> 
>> Cheers,
>> Alan.
>>   
>> From: Nuno Agostinho <nunodanielagosti...@gmail.com 
>> <mailto:nunodanielagosti...@gmail.com>>
>> Sent: 03 June 2021 11:57
>> To: Murphy, Alan E <a.mur...@imperial.ac.uk <mailto:a.mur...@imperial.ac.uk>>
>> Cc: bioc-devel@r-project.org <mailto:bioc-devel@r-project.org> 
>> <bioc-devel@r-project.org <mailto:bioc-devel@r-project.org>>
>> Subject: Re: [Bioc-devel] Add dockerhub push to github repository
>>  
>> This email from nunodanielagosti...@gmail.com 
>> <mailto:nunodanielagosti...@gmail.com> originates from outside Imperial. Do 
>> not click on links and attachments unless you recognise the sender. If you 
>> trust the sender, add them to your safe senders list 
>> <https://spam.ic.ac.uk/SpamConsole/Senders.aspx> to disable email stamping 
>> for this address. 
>>  
>> Hey Alan,
>> 
>>> I would like to automatically create a new image and push to dockerhub with 
>>> github actions when I push changes to the github repository. Does anyone 
>>> have an example of this process in their repositories?
>> 
>> 
>> Well, I use GitHub actions to build a Docker image and push it to GitHub 
>> Container Registry, maybe this could help somehow: 
>> https://github.com/nuno-agostinho/psichomics/blob/master/.github/workflows/docker.yml
>>  
>> <https://github.com/nuno-agostinho/psichomics/blob/master/.github/workflows/docker.yml>
>> 
>> I use GitHub releases to release a new package version and, every time I 
>> release a new version, a new Docker image is built (this image also gets 
>> automatically tagged with the latest tag). I also build Docker images every 
>> time I push changes to the dev branch.
>> 
>> Regarding DockerHub, I have DockerHub set up to automatically build Docker 
>> images every time I push to master (to create the latest tag) and dev 
>> branches in GitHub, as well as every time I create a new tag (which I do 
>> when creating new releases). I could put this in the GitHub actions, but I 
>> didn't bother yet.
>> 
>>> I would ideally like the tag of this dockerhub push to be the R package 
>>> version (from the DESCRIPTION) to differentiate between images, is this 
>>> possible?
>> 
>> I think you can run some bash script in your GitHub Actions based on your 
>> DESCRIPTION file. I would have to test but maybe something like:
>> 
>>     - name: Get R package version
>>       run: |
>>         version=$(grep Version DESCRIPTION | grep -o "[0-9.]\+")
>>         echo "packageVersion=${version}" >> $GITHUB_ENV
>>       shell:
>>         bash {0}
>> 
>> You can then access this variable in other steps via ${{ env.packageVersion 
>> }} like so:
>> 
>>     - name: Build and push
>>       uses: docker/build-push-action@v2
>>       with:
>>         push: true
>>         tags: ${{ github.repository }}:${{ env.packageVersion }}
>> 
>>> Is there a way to tell the Dockerfile to install the R package in the 
>>> current repository?
>> 
>> 
>> To build the image, I use ADD . . to put the GitHub repository content in 
>> the Docker image and then install the package using 
>> remotes::install_local(), as you can see from my Dockerfile: 
>> https://github.com/nuno-agostinho/psichomics/blob/master/Dockerfile 
>> <https://github.com/nuno-agostinho/psichomics/blob/master/Dockerfile>
>> 
>> I hope I was clear and helpful. Please tell me if you need help with 
>> anything else! :)
>> 
>> Best,
>> Nuno Agostinho
>> 
>>> On 3 Jun 2021, at 07:52, Murphy, Alan E <a.mur...@imperial.ac.uk 
>>> <mailto:a.mur...@imperial.ac.uk>> wrote:
>>> 
>>> Hi all,
>>> 
>>> I'm working on developing an R package with the aim to eventually submit to 
>>> Bioconductor. I would like to automatically create a new image and push to 
>>> dockerhub with github actions when I push changes to the github repository. 
>>> Does anyone have an example of this process in their repositories?
>>> 
>>> Two things to also consider, I would ideally like the tag of this dockerhub 
>>> push to be the R package version (from the DESCRIPTION) to differentiate 
>>> between images, is this possible? Secondly, I currently have the dockerfile 
>>> created but, since my R package repository is private I have been building 
>>> the R package and using the tar.gz file in the dockerfile to install the 
>>> package (rather than using devtools::install_github()). Is there a way to 
>>> tell the Dockerfile to install the R package in the current repository?
>>> 
>>> Kind regards,
>>> Alan.
>>> 
>>> Alan Murphy
>>> Bioinformatician
>>> Neurogenomics lab
>>> UK Dementia Research Institute
>>> Imperial College London
>>> 
>>> [[alternative HTML version deleted]]
>>> 
>>> _______________________________________________
>>> Bioc-devel@r-project.org <mailto:Bioc-devel@r-project.org> mailing list
>>> https://stat.ethz.ch/mailman/listinfo/bioc-devel 
>>> <https://stat.ethz.ch/mailman/listinfo/bioc-devel>

        [[alternative HTML version deleted]]

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to