push2ghcrio #4
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: push2ghcrio | |
on: | |
repository_dispatch: | |
types: [backend_automation] | |
workflow_dispatch: | |
jobs: | |
docker_schedule: | |
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule') | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- microbiomedata/bbtools:38.96 | |
- microbiomedata/spades:3.15.0 | |
runs-on: ubuntu-latest | |
timeout-minutes: 420 | |
steps: | |
- name: Login to GitHub Container Registry | |
if: ${{ github.actor == github.repository_owner }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: new image name | |
run: | | |
echo "new_image_name=$(echo ${{ matrix.image }}) | sed 's/\//-/' | sed 's/:/-/' >> $GITHUB_ENV | |
shell: bash | |
- name: docker tag | |
run: | | |
echo "tag=ghcr.io/${{ github.actor }}/docker2ghcrio-${{ env.new_image_name }}" >> $GITHUB_ENV | |
shell: bash | |
- name: echo docker tag to env | |
id: env_tag | |
run: | |
echo "tag=${{ env.tag }}" >> $GITHUB_OUTPUT | |
- name: build date | |
id: build-date | |
run: | | |
echo "date=$(TZ=America/Los_Angeles date +%Y%m%d_%H%M%S)" >> $GITHUB_ENV | |
- name: print env | |
run: | | |
echo "GITHUB_ENV" `cat $GITHUB_ENV` | |
echo " tag " ${{ env.tag }} | |
- name: pull image from docker hub and push it to ghcr.io | |
run: | | |
docker pull ${{ matrix.image }} | |
docker save -o myimagetar ${{ matrix.image }} | |
docker tag ${{ matrix.image }} ${{ env.tag }} | |
docker images | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
docker push ${{ env.tag }} | |
- name: pull image from ghcr.io and test it | |
run: | | |
docker pull ${{ env.tag }} | |
docker run --rm ${{ env.tag }} ls -lrt / | |