|
1 |
| -name: Build & Publish Docker Images |
| 1 | +name: Build & Publish Changed Docker Images |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
|
19 | 19 | uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
|
20 | 20 | - name: "Calculate changed files directories"
|
21 | 21 | id: calculate_changed_files
|
22 |
| - uses: tj-actions/changed-files@5426ecc3f5c2b10effaefbd374f0abdc6a571b2f |
| 22 | + uses: tj-actions/changed-files@c34c1c13a740b06851baff92ab9a653d93ad6ce7 |
23 | 23 | with:
|
24 | 24 | dir_names: true
|
25 | 25 | dir_names_exclude_current_dir: true
|
@@ -47,61 +47,38 @@ jobs:
|
47 | 47 | - name: Checkout repository
|
48 | 48 | uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
|
49 | 49 | - name: Log in to the Container Registry
|
50 |
| - uses: docker/login-action@6d4b68b490aef8836e8fb5e50ee7b3bdfa5894f0 |
| 50 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 |
51 | 51 | with:
|
52 | 52 | registry: ${{ env.REGISTRY }}
|
53 | 53 | username: ${{ github.actor }}
|
54 | 54 | password: ${{ secrets.GITHUB_TOKEN }}
|
55 | 55 | - name: Extract Details From config.yml
|
56 | 56 | id: extract_from_config_yaml
|
57 |
| - run: | |
58 |
| - echo "desired_version=$(cat ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yml | yq '.version')" >> "$GITHUB_OUTPUT" |
59 |
| - echo "platforms=$(cat ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yml | yq '.platforms | join(",")')" >> "$GITHUB_OUTPUT" |
60 |
| - echo "description=$(cat ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yml | yq '.description')" >> "$GITHUB_OUTPUT" |
| 57 | + uses: ./.github/workflows/extract_details_from_config.yml |
| 58 | + with: |
| 59 | + config_yaml_path: ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yaml |
61 | 60 | - name: Check Image to Build Does Not Already Exist
|
62 | 61 | run: |
|
63 |
| - if docker manifest inspect ${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }}:${{ steps.extract_from_config_yaml.outputs.desired_version }} > /dev/null; then |
64 |
| - echo "The tag "${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }}:${{ steps.extract_from_config_yaml.outputs.desired_version }}" already exists in the repository. Do you need to bump the version in the config.yml?" |
| 62 | + if docker manifest inspect ${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }}:${{ steps.extract_from_config_yaml.outputs.current_version }} > /dev/null; then |
| 63 | + echo "The tag "${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }}:${{ steps.extract_from_config_yaml.outputs.current_version }}" already exists in the repository. Do you need to bump the version in the config.yml?" |
65 | 64 | exit 1
|
66 | 65 | fi
|
67 | 66 | - name: Calculate Version
|
68 | 67 | id: calculate_version
|
69 | 68 | run: |
|
70 |
| - VERSION=${{ github.event_name == 'pull_request' && format('{0}-PR{1}.{2}', steps.extract_from_config_yaml.outputs.desired_version, github.event.number, github.event.pull_request.head.sha) || steps.extract_from_config_yaml.outputs.desired_version}} |
| 69 | + VERSION=${{ github.event_name == 'pull_request' && format('{0}-PR{1}.{2}', steps.extract_from_config_yaml.outputs.current_version, github.event.number, github.event.pull_request.head.sha) || steps.extract_from_config_yaml.outputs.current_version}} |
71 | 70 | echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
72 |
| - - name: Set up Docker Buildx |
73 |
| - uses: docker/setup-buildx-action@e600775e527acba2317260cadb64b7e19efd5362 |
74 |
| - - name: Get Docker Metadata |
75 |
| - id: meta |
76 |
| - uses: docker/metadata-action@418e4b98bf2841bd337d0b24fe63cb36dc8afa55 |
77 |
| - env: |
78 |
| - DOCKER_METADATA_PR_HEAD_SHA: true |
| 71 | + - name: Build Docker Image (${{ matrix.changed_dir }}) |
| 72 | + uses: ./.github/workflows/build_docker_image.yml |
79 | 73 | with:
|
80 |
| - images: ${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }} |
| 74 | + description: ${{ steps.extract_from_config_yaml.outputs.description }} |
| 75 | + directory: ${{ github.workspace }}/${{ matrix.changed_dir }} |
| 76 | + image_name: ${{ matrix.changed_dir }} |
| 77 | + image_registry: ${{ env.NAMESPACED_REGISTRY }} |
| 78 | + platforms: ${{ steps.extract_from_config_yaml.outputs.platforms }} |
81 | 79 | tags: |
|
82 |
| - type=semver,pattern={{version}},value=v${{ steps.calculate_version.outputs.version }} |
| 80 | + type=semver,pattern={{version}},value=v${{ inputs.version }} |
83 | 81 | type=sha,prefix=
|
84 |
| - labels: | |
85 |
| - org.opencontainers.image.title=${{ matrix.changed_dir }} |
86 |
| - org.opencontainers.image.description=${{ steps.extract_from_config_yaml.outputs.description }} |
87 |
| - org.opencontainers.image.vendor=Apollo GraphQL |
88 |
| - org.opencontainers.image.licenses=MIT |
89 |
| - annotations: | |
90 |
| - org.opencontainers.image.title=${{ matrix.changed_dir }} |
91 |
| - org.opencontainers.image.description=${{ steps.extract_from_config_yaml.outputs.description }} |
92 |
| - org.opencontainers.image.vendor=Apollo GraphQL |
93 |
| - org.opencontainers.image.licenses=MIT |
94 |
| - - name: Build and Push Docker image |
95 |
| - id: push |
96 |
| - uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 |
97 |
| - with: |
98 |
| - context: ${{ github.workspace }}/${{ matrix.changed_dir }} |
99 |
| - file: ${{ github.workspace }}/${{ matrix.changed_dir }}/Dockerfile |
100 |
| - push: true |
101 |
| - tags: ${{ steps.meta.outputs.tags }} |
102 |
| - annotations: ${{ steps.meta.outputs.annotations }} |
103 |
| - labels: ${{ steps.meta.outputs.labels }} |
104 |
| - platforms: ${{ steps.extract_from_config_yaml.outputs.platforms }} |
105 | 82 | - name: Create Git Tag
|
106 | 83 | uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b
|
107 | 84 | with:
|
|
0 commit comments