Install R pkgs from gh (#199) #190
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
on: | |
push: | |
branches: [main] | |
tags: [v*] | |
pull_request: | |
workflow_dispatch: | |
env: | |
IMAGE_NAME: workflow.transition.monitor | |
jobs: | |
Docker-build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
timeout-minutes: 25 | |
steps: | |
- name: Checkout workflow.transition.monitor | |
uses: actions/checkout@v3 | |
with: | |
path: workflow.transition.monitor | |
- name: Make fake (empty) pacta-data folder | |
run: mkdir pacta-data | |
- name: Make fake (empty) templates.transition.monitor folder | |
run: mkdir templates.transition.monitor | |
- name: Build Docker image | |
run: | | |
cp workflow.transition.monitor/Dockerfile Dockerfile | |
docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Push image | |
id: push-image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "main" ] && VERSION=latest | |
# if from a PR, use the PR number | |
[ "$VERSION" == "merge" ] && VERSION=$(echo "PR${{ github.event.pull_request.number }}") | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
echo "BUILD_NAME_TAG=$IMAGE_ID:$VERSION" >> $GITHUB_OUTPUT | |
- name: Find Comment | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
token: ${{ secrets.PAT_ADD_ISSUES_TO_PROJECT }} | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Docker image from this PR created | |
- name: Create or update comment | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
token: ${{ secrets.PAT_ADD_ISSUES_TO_PROJECT }} | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Docker image from this PR created | |
``` | |
docker pull ${{ steps.push-image.outputs.BUILD_NAME_TAG }} | |
``` | |
edit-mode: replace | |