-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Dockerfile to resolve build issues due to vintage #131
base: master
Are you sure you want to change the base?
Changes from all commits
64e1059
7a86c3e
6bcfd19
655cec7
e83e997
22bcf11
422aba6
2226d7a
792f639
7c5648d
3385c7d
701b080
95d23c3
09551c3
7ee72c5
42f6733
0c24711
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,7 @@ name: build-test | |||||
# but not on master or tags | ||||||
# and only for Dockerfile related modifications | ||||||
on: | ||||||
workflow_dispatch: | ||||||
push: | ||||||
tags-ignore: | ||||||
- "**" | ||||||
|
@@ -22,30 +23,14 @@ env: | |||||
IMAGE_NAME: "terraform-azure-cli" | ||||||
|
||||||
jobs: | ||||||
load_supported_versions: | ||||||
runs-on: ubuntu-20.04 | ||||||
|
||||||
outputs: | ||||||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||||||
|
||||||
steps: | ||||||
- name: Check out the repo | ||||||
uses: actions/checkout@v3 | ||||||
|
||||||
- name: Save supported versions as output | ||||||
id: set-matrix | ||||||
run: | | ||||||
SUPPORTED_VERSIONS=$(cat ./supported_versions.json) | ||||||
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//'%'/%25}" | ||||||
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\n'/%0A}" | ||||||
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\r'/%0D}" | ||||||
echo "::set-output name=matrix::${SUPPORTED_VERSIONS}" | ||||||
load_versions: | ||||||
uses: ./.github/workflows/include_supported-versions.yml | ||||||
|
||||||
build: | ||||||
build_containers: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this job build container images, it would be renamed:
Suggested change
|
||||||
runs-on: ubuntu-20.04 | ||||||
needs: load_supported_versions | ||||||
needs: load_versions | ||||||
strategy: | ||||||
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }} | ||||||
matrix: ${{ fromJSON(needs.load_versions.outputs.matrix) }} | ||||||
|
||||||
steps: | ||||||
- name: Check out the repo | ||||||
|
@@ -55,54 +40,21 @@ jobs: | |||||
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV | ||||||
|
||||||
- name: Build and save image tag | ||||||
run: echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV | ||||||
|
||||||
run: | | ||||||
echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV | ||||||
echo $IMAGE_TAG | ||||||
|
||||||
- name: Build image | ||||||
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ matrix.tf_version }} --build-arg AZURE_CLI_VERSION=${{ matrix.azcli_version }} --tag ${IMAGE_NAME}:${IMAGE_TAG} | ||||||
|
||||||
- name: Save image | ||||||
run: docker image save --output ${IMAGE_NAME}_${IMAGE_TAG}.tar ${IMAGE_NAME}:${IMAGE_TAG} | ||||||
|
||||||
- name: Upload image artifact | ||||||
uses: actions/upload-artifact@v2 | ||||||
with: | ||||||
name: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }} | ||||||
path: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}.tar | ||||||
|
||||||
test: | ||||||
runs-on: ubuntu-20.04 | ||||||
needs: | ||||||
- build | ||||||
- load_supported_versions | ||||||
strategy: | ||||||
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }} | ||||||
|
||||||
steps: | ||||||
- name: Checkout source | ||||||
uses: actions/checkout@v3 | ||||||
|
||||||
- name: Save branch name as env var | ||||||
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV | ||||||
|
||||||
- name: Build and save image tag | ||||||
run: echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV | ||||||
|
||||||
- name: Download image artifact | ||||||
uses: actions/download-artifact@v2 | ||||||
with: | ||||||
name: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }} | ||||||
|
||||||
- name: Load image | ||||||
run: docker image load --input ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}.tar | ||||||
|
||||||
- name: Generate test config | ||||||
run: | | ||||||
export TF_VERSION=${{ matrix.tf_version }} | ||||||
export AZ_VERSION=${{ matrix.azcli_version }} | ||||||
envsubst '${TF_VERSION},${AZ_VERSION}' < tests/container-structure-tests.yml.template > tests/container-structure-tests.yml | ||||||
|
||||||
- name: run structure tests | ||||||
uses: plexsystems/container-structure-test-action@v0.2.0 | ||||||
uses: plexsystems/container-structure-test-action@v0.3.0 | ||||||
with: | ||||||
image: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | ||||||
config: tests/container-structure-tests.yml |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||
name: Load Supported Versions | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you stated in the name, it might be better to keep the file name plural as latest version is exposed for multi tools, what do you think ? That would be: .github/workflows/include_latest-versions.yml |
||||||
|
||||||
on: | ||||||
workflow_call: | ||||||
outputs: | ||||||
azcli_version: | ||||||
description: "Latest supported azcli version" | ||||||
value: ${{ jobs.load_versions.outputs.azcli_version }} | ||||||
tf_version: | ||||||
description: "Latest supported terraform version" | ||||||
value: ${{ jobs.load_versions.outputs.tf_version }} | ||||||
workflow_dispatch: | ||||||
|
||||||
jobs: | ||||||
load_versions: | ||||||
runs-on: ubuntu-20.04 | ||||||
outputs: | ||||||
azcli_version: ${{ env.azcli_version }} | ||||||
tf_version: ${{ env.tf_version }} | ||||||
|
||||||
steps: | ||||||
- name: Check out the repo | ||||||
uses: actions/checkout@v3 | ||||||
|
||||||
- name: Save supported versions as output | ||||||
id: set-matrix | ||||||
run: | | ||||||
echo "azcli_version=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV | ||||||
echo "tf_version=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV | ||||||
|
||||||
- name: output | ||||||
run: | | ||||||
echo $azcli_version | ||||||
echo $tf_version | ||||||
|
||||||
display_versions: | ||||||
needs: load_versions | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Access Variable | ||||||
run: | | ||||||
echo "azcli_version=${{ needs.load_versions.outputs.azcli_version }}" | ||||||
echo "tf_version=${{ needs.load_versions.outputs.tf_version }}" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||
name: Load Supported Versions | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I didn't understand correctly, but aren't The only difference I can sport is EDIT : In that cas, a plural on outputs would be nice 😉 |
||||||
|
||||||
on: | ||||||
workflow_call: | ||||||
outputs: | ||||||
matrix: | ||||||
description: "Matrix of supported versions" | ||||||
value: ${{ jobs.load_versions.outputs.matrix }} | ||||||
azcli_version: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Beware of references elsewhere in the code |
||||||
description: "Matrix of supported azcli versions" | ||||||
value: ${{ jobs.load_versions.outputs.azcli_version }} | ||||||
tf_version: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Beware of references elsewhere in the code |
||||||
description: "Matrix of supported terraform versions" | ||||||
value: ${{ jobs.load_versions.outputs.tf_version }} | ||||||
workflow_dispatch: | ||||||
|
||||||
jobs: | ||||||
load_versions: | ||||||
runs-on: ubuntu-20.04 | ||||||
outputs: | ||||||
azcli_version: ${{ env.azcli_version }} | ||||||
tf_version: ${{ env.tf_version }} | ||||||
matrix: ${{ env.matrix }} | ||||||
|
||||||
steps: | ||||||
- name: Check out the repo | ||||||
uses: actions/checkout@v3 | ||||||
|
||||||
- name: Save supported versions as output | ||||||
id: set-matrix | ||||||
run: | | ||||||
echo "azcli_version=$(jq -r -c '.azcli_version | sort | reverse' supported_versions.json)" >> $GITHUB_ENV | ||||||
echo "tf_version=$(jq -r -c '.tf_version | sort | reverse' supported_versions.json)" >> $GITHUB_ENV | ||||||
echo -e matrix=\{"azcli_version": $(jq -r -c '.azcli_version | sort | reverse' supported_versions.json), "tf_version": $(jq -r -c '.tf_version | sort | reverse' supported_versions.json)\} >> $GITHUB_ENV | ||||||
|
||||||
- name: output | ||||||
run: | | ||||||
echo $azcli_version | ||||||
echo $tf_version | ||||||
echo $matrix | ||||||
|
||||||
display_versions: | ||||||
needs: load_versions | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Access Variable | ||||||
run: | | ||||||
echo "azcli_version=${{ needs.load_versions.outputs.azcli_version }}" | ||||||
echo "tf_version=${{ needs.load_versions.outputs.tf_version }}" | ||||||
echo "matrix=${{ needs.load_versions.outputs.matrix }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,37 +15,35 @@ on: | |
- ".github/workflows/push-latest.yml" | ||
|
||
env: | ||
ORGANIZATION: "zenika" | ||
IMAGE_NAME: "terraform-azure-cli" | ||
IMAGE_TAG: "latest" | ||
|
||
jobs: | ||
latest_version: | ||
uses: ./.github/workflows/include_latest-version.yml | ||
|
||
build_push_latest: | ||
runs-on: ubuntu-20.04 | ||
needs: latest_version | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Retrieve latest suported versions | ||
run: | | ||
echo "AZ_VERSION=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV | ||
echo "TF_VERSION=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV | ||
|
||
- name: Build image | ||
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${TF_VERSION} --build-arg AZURE_CLI_VERSION=${AZ_VERSION} --tag $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG | ||
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ needs.latest_version.outputs.tf_version }} --build-arg AZURE_CLI_VERSION=${{ needs.latest_version.outputs.azcli_version }} --tag ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$IMAGE_TAG | ||
|
||
- name: Login to Docker Hub registry | ||
run: echo '${{ secrets.DOCKERHUB_PASS }}' | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
|
||
- name: Push image to registry | ||
run: docker push $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$IMAGE_TAG | ||
|
||
- name: Save image | ||
run: docker image save -o $IMAGE_NAME-$IMAGE_TAG.tar $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG | ||
run: docker image save -o $IMAGE_NAME-$IMAGE_TAG.tar ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$IMAGE_TAG | ||
Comment on lines
-42
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerhub_username secret might not alway be "Zenika" and is not intended to identify the container registry name, so I would suggest to keep the |
||
|
||
- name: Upload image artifact | ||
uses: actions/upload-artifact@v2 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }} | ||
path: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}.tar |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,35 +6,18 @@ on: | |
types: [published] | ||
|
||
jobs: | ||
load_supported_versions: | ||
runs-on: ubuntu-20.04 | ||
|
||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Save supported versions as output | ||
id: set-matrix | ||
run: | | ||
SUPPORTED_VERSIONS=$(cat ./supported_versions.json) | ||
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//'%'/%25}" | ||
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\n'/%0A}" | ||
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\r'/%0D}" | ||
echo "::set-output name=matrix::${SUPPORTED_VERSIONS}" | ||
load_versions: | ||
uses: ./.github/workflows/include_supported-versions.yml | ||
|
||
build_push_release: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- load_supported_versions | ||
- load_versions | ||
|
||
strategy: | ||
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }} | ||
matrix: ${{ fromJSON(needs.load_versions.outputs.matrix) }} | ||
|
||
env: | ||
ORGANIZATION: "zenika" | ||
IMAGE_NAME: "terraform-azure-cli" | ||
|
||
steps: | ||
|
@@ -48,19 +31,21 @@ jobs: | |
run: echo "IMAGE_RELEASE_TAG=release-${RELEASE_TAG}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV | ||
|
||
- name: Build image | ||
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ matrix.tf_version }} --build-arg AZURE_CLI_VERSION=${{ matrix.azcli_version }} --tag ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG} | ||
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ matrix.tf_version }} --build-arg AZURE_CLI_VERSION=${{ matrix.azcli_version }} --tag ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG} | ||
Comment on lines
-51
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same feedback as in push-latest workflow, we might be better off keeping ORGANIZATION env var |
||
|
||
- name: Login to Docker Hub registry | ||
run: echo '${{ secrets.DOCKERHUB_PASS }}' | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
|
||
- name: Push image to registry | ||
run: docker push ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG} | ||
run: | | ||
docker images | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG} | ||
|
||
- name: Save image | ||
run: docker image save -o ${IMAGE_NAME}-${IMAGE_RELEASE_TAG}.tar ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG} | ||
run: docker image save -o ${IMAGE_NAME}-${IMAGE_RELEASE_TAG}.tar ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG} | ||
|
||
- name: Upload image artifact | ||
uses: actions/upload-artifact@v2 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_RELEASE_TAG }} | ||
path: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_RELEASE_TAG }}.tar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: test_supported-versions.yaml | ||
on: | ||
push: | ||
jobs: | ||
load_versions: | ||
uses: ./.github/workflows/include_supported-versions.yml | ||
|
||
latest_version: | ||
uses: ./.github/workflows/include_latest-version.yml | ||
|
||
check_values: | ||
runs-on: ubuntu-latest | ||
needs: load_versions | ||
strategy: | ||
matrix: ${{ fromJSON(needs.load_versions.outputs.matrix) }} | ||
steps: | ||
- name: Test access to values | ||
run: | | ||
echo ${{ needs.load_versions.outputs.matrix }} | ||
echo tf_${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }} | ||
|
||
check_latest: | ||
runs-on: ubuntu-latest | ||
needs: latest_version | ||
steps: | ||
- name: Test access to values | ||
run: | | ||
echo terraform: ${{ needs.latest_version.outputs.tf_version }} | ||
echo azcli: ${{ needs.latest_version.outputs.azcli_version }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using reusables workflow is a very nice addition, much more DRY this way !
If possible, it might be a good idea to shrink their names and store them in a subdirectories, for instance
.github/workflows/reusables/latest-version.yml
. What do you think ?