|
1 | | -name: Build |
| 1 | +name: Build and Publish Image |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: |
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | push: |
8 | | - branches: [main] |
| 8 | + branches: |
| 9 | + - main |
9 | 10 | release: |
10 | | - types: ['published'] |
11 | | - workflow_dispatch: |
12 | | - inputs: |
13 | | - tagName: |
14 | | - description: 'Tag of the image you want to build and push' |
15 | | - required: true |
| 11 | + types: ["published"] |
16 | 12 |
|
17 | 13 | jobs: |
18 | | - build: |
19 | | - runs-on: ubuntu-latest |
20 | | - steps: |
21 | | - - name: Checkout |
22 | | - uses: actions/checkout@v2 |
23 | | - |
24 | | - - name: Prepare |
25 | | - id: prep |
26 | | - run: | |
27 | | - DOCKER_IMAGE=cmusei/caster-ui |
28 | | - VERSION=development |
29 | | - if [[ ! -z "${{ github.event.inputs.tagName }}" ]]; then |
30 | | - VERSION=${{ github.event.inputs.tagName }} |
31 | | - TAGS="${DOCKER_IMAGE}:${VERSION}" |
32 | | - elif [[ $GITHUB_REF == refs/tags/* ]]; then |
33 | | - VERSION=${GITHUB_REF#refs/tags/} |
34 | | - MAJORMINORVERSION=$(echo $VERSION | grep -oP '(\d+)\.(\d+)') |
35 | | - TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${MAJORMINORVERSION}" |
36 | | - elif [[ $GITHUB_REF == refs/heads/* ]]; then |
37 | | - VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') |
38 | | - TAGS="${DOCKER_IMAGE}:${VERSION}" |
39 | | - fi |
40 | | - if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
41 | | - echo ::set-output name=push::false |
42 | | - echo "event is pull_request, not pushing image" |
43 | | - else |
44 | | - echo ::set-output name=push::true |
45 | | - echo "event is not pull_request, pushing image" |
46 | | - fi |
47 | | - echo ::set-output name=version::${VERSION} |
48 | | - echo ::set-output name=tags::${TAGS} |
49 | | - echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
50 | | -
|
51 | | - - name: Set up Docker Buildx |
52 | | - uses: docker/setup-buildx-action@v1 |
53 | | - |
54 | | - - name: Login to DockerHub |
55 | | - if: github.event_name != 'pull_request' |
56 | | - uses: docker/login-action@v1 |
57 | | - with: |
58 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
59 | | - password: ${{ secrets.DOCKERHUB_PASSWORD }} |
60 | | - |
61 | | - - name: Build and push |
62 | | - uses: docker/build-push-action@v2 |
63 | | - with: |
64 | | - context: . |
65 | | - file: ./Dockerfile |
66 | | - push: ${{ steps.prep.outputs.push }} |
67 | | - pull: true |
68 | | - tags: ${{ steps.prep.outputs.tags }} |
69 | | - labels: | |
70 | | - org.opencontainers.image.source=${{ github.event.repository.clone_url }} |
71 | | - org.opencontainers.image.created=${{ steps.prep.outputs.created }} |
72 | | - org.opencontainers.image.revision=${{ github.sha }} |
| 14 | + build-and-publish: |
| 15 | + name: Build and Publish |
| 16 | + uses: cmu-sei/Crucible-Github-Actions/.github/workflows/docker-build.yaml@docker-v1.1.2 |
| 17 | + with: |
| 18 | + imageName: cmusei/caster-ui |
| 19 | + versionMode: npm |
| 20 | + versionFiles: package.json |
| 21 | + secrets: |
| 22 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 23 | + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
0 commit comments