Merge pull request #7 from LANL-Bioinformatics/revert-5-revert-4-upda… #2
This file contains hidden or 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 push container contigs_taxonomy | |
| # Run this workflow whenever a Dockerfile is updated. | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'workflows/Nextflow/metagenomics/nextflow/modules/contigsTaxonomyAssignment/Dockerfile' | |
| jobs: | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout branch | |
| uses: actions/checkout@v4 | |
| - name: Get Version | |
| id: get_version | |
| run: | | |
| VERSION=$(grep -oP 'version=\K.*' workflows/Nextflow/metagenomics/nextflow/modules/contigsTaxonomyAssignment/Dockerfile) | |
| VERSION=${VERSION:-1.0.0} | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Authenticate with container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Use the `docker/build-push-action` action to build the image described | |
| # by the specified Dockerfile. If the build succeeds, push the image to GHCR. | |
| # This action uses the `tags` parameters to tag the image with the Git tag name | |
| # the image, respectively, with the output from the "get_version" step above. | |
| # For more info: https://github.com/docker/build-push-action#usage. | |
| - name: Build and push container image | |
| id: push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: workflows/Nextflow/metagenomics/nextflow/modules/contigsTaxonomyAssignment | |
| file: workflows/Nextflow/metagenomics/nextflow/modules/contigsTaxonomyAssignment/Dockerfile | |
| push: true | |
| tags: ghcr.io/lanl-bioinformatics/edge_contigs_taxonomy:${{ steps.get_version.outputs.version }} | |
| - name: update image tag ID and version in the config | |
| run: | | |
| imageName="ghcr.io/lanl-bioinformatics/edge_contigs_taxonomy:${{ steps.get_version.outputs.version }}" | |
| version="${{ steps.get_version.outputs.version }}" | |
| sed -i -E "s#apwat/contigs_taxonomy:[0-9a-zA-Z._-]+#${imageName}#" workflows/Nextflow/metagenomics/configs/container.config | |
| sed -i -E "s#edge_contigs_taxonomy:[0-9a-zA-Z._-]+#edge_contigs_taxonomy:${version}#" workflows/Nextflow/metagenomics/configs/container.config | |
| sed -i -E "s#apwat/contigs_taxonomy:[0-9a-zA-Z._-]+#${imageName}#" workflows/Nextflow/metagenomics/nextflow/nextflow.config | |
| sed -i -E "s#edge_contigs_taxonomy:[0-9a-zA-Z._-]+#edge_contigs_taxonomy:${version}#" workflows/Nextflow/metagenomics/nextflow/nextflow.config | |
| #A GitHub Action to detect changed files during a Workflow run and to commit and push them back to the GitHub repository. | |
| #By default, the commit is made in the name of "GitHub Actions" and co-authored by the user that made the last commit. | |
| - name: auto-commit image version update | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| branch: auto-update-${{ github.run_id }} | |
| create_branch: true | |
| commit_message: "Auto update of run contigtaxonomy docker image version ${{ steps.get_version.outputs.version }}" | |
| - name: Create Pull Request | |
| run: | | |
| title="Automated PR: update contigtaxonomy docker image version ${{ steps.get_version.outputs.version }}" | |
| gh pr create \ | |
| --base main \ | |
| --head auto-update-${{ github.run_id }} \ | |
| --title "$title" \ | |
| --body "Created by GitHub Action" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |