-
Notifications
You must be signed in to change notification settings - Fork 8
47 lines (44 loc) · 2.26 KB
/
Copy pathbuild-and-push-image.yml
File metadata and controls
47 lines (44 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Build and push img-omics container image to GHCR
# Run this workflow whenever a Dockerfile is updated.
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'Dockerfile'
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get Version
id: get_version
run: |
VERSION=$(grep "IMG_annotation_pipeline_ver=" Dockerfile | cut -d"=" -f 2 | head -n 1)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Authenticate with container registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
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@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
file: Dockerfile
push: true
tags: ghcr.io/microbiomedata/nmdc-img-annotation-pipeline:${{ steps.get_version.outputs.version }}
# References:
# - https://docs.github.com/en/actions/learn-github-actions/variables#using-the-vars-context-to-access-configuration-variable-values
# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
# - https://github.com/microbiomedata/nmdc-edge/blob/main/.github/workflows/build-and-push-image.yml
# - https://stackoverflow.com/questions/59191913/how-do-i-get-the-output-of-a-specific-step-in-github-actions